com web/master: rename the variable holding the PR description to not collide with the request body variable with the same name: github-webhook.php
| From: | Ferenc Kovacs | Date: | Tue, 10 Jun 2014 20:00:03 +0000 |
| Subject: | com web/master: rename the variable holding the PR description to not collide with the request body variable with the same name: github-webhook.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-19224@lists.php.net to get a copy of this message | ||
Commit: 5f50ef481f93a8390b4a2e532514fbe6667adacb
Author: kovacs.ferenc <kovacs.ferenc@ustream.tv> Tue, 10 Jun 2014 22:00:03 +0200
Parents: 399ecb7fbc24279b0b04b887c99ef08397358e1b
Branches: master
Link: http://git.php.net/?p=web/master.git;a=commitdiff;h=5f50ef481f93a8390b4a2e532514fbe6667adacb
Log:
rename the variable holding the PR description to not collide with the request body variable with
the same name
Changed paths:
M github-webhook.php
Diff:
diff --git a/github-webhook.php b/github-webhook.php
index 8b57684..b7fedda 100644
--- a/github-webhook.php
+++ b/github-webhook.php
@@ -7,9 +7,9 @@ $config = array(
),
);
-$body = file_get_contents("php://input");
+$description = file_get_contents("php://input");
-if (!verify_signature($body)) {
+if (!verify_signature($description)) {
header('HTTP/1.1 403 Forbidden');
exit;
}
@@ -18,13 +18,13 @@ switch ($_SERVER['HTTP_X_GITHUB_EVENT']) {
case 'ping':
break;
case 'pull_request':
- $payload = json_decode($body);
+ $payload = json_decode($description);
$action = $payload->action;
$PRNumber = $payload->number;
$PR = $payload->pull_request;
$htmlUrl = $PR->html_url;
$title = $PR->title;
- $body = $PR->body;
+ $description = $PR->body;
$repoName = $PR->base->repo->name;
$targetBranch = $PR->base->ref;
@@ -43,9 +43,7 @@ switch ($_SERVER['HTTP_X_GITHUB_EVENT']) {
if ($mergeable === false) {
$message .= "\r\n\r\nWarning: according to github, the Pull Request cannot be merged
without manual conflict resolution!";
}
- if ($body) {
- $message .= sprintf("\r\n\r\nPull Request Description:\r\n%s", $body);
- }
+ $message .= sprintf("\r\n\r\nPull Request Description:\r\n%s", $description);
$headers = "From: noreply@php.net\r\nContent-Type: text/plain; charset=utf-8\r\n";
mail($to, '=?utf-8?B?'.base64_encode($subject).'?=', $message, $headers);
break;