Skip to content

Commit 616b8c8

Browse files
committed
Retrieve commit payload from message body
Backported from 99ec266. The legacy MantisBT GitHub Service sends the push's payload via eponymous form variable. With the retirement of this service and its replacement by webhooks, the payload is now contained in the body. Fixes #292
1 parent b37c665 commit 616b8c8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

SourceGithub/SourceGithub.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,14 @@ private function api_json_url( $p_repo, $p_url, $p_member = null ) {
248248
}
249249

250250
public function precommit() {
251+
# Legacy GitHub Service sends the payload via eponymous form variable
251252
$f_payload = gpc_get_string( 'payload', null );
252253
if ( is_null( $f_payload ) ) {
253-
return;
254+
# If empty, retrieve the webhook's payload from the body
255+
$f_payload = file_get_contents( 'php://input' );
256+
if ( is_null( $f_payload ) ) {
257+
return;
258+
}
254259
}
255260

256261
if ( false === stripos( $f_payload, 'github.com' ) ) {

0 commit comments

Comments
 (0)