From 5b0d8c94703dc1a678e493fdca33f9108a1dfae2 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Tue, 12 Sep 2017 13:55:21 -0400 Subject: [PATCH 1/2] Caches the github diff for has_tree_been_edited (#30578) --- tools/WebhookProcessor/github_webhook_processor.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/WebhookProcessor/github_webhook_processor.php b/tools/WebhookProcessor/github_webhook_processor.php index 0ee66acabf..dde21e4f43 100644 --- a/tools/WebhookProcessor/github_webhook_processor.php +++ b/tools/WebhookProcessor/github_webhook_processor.php @@ -358,13 +358,18 @@ function auto_update($payload){ fclose($code_file); } +$github_diff = null; + function has_tree_been_edited($payload, $tree){ - //go to the diff url - $url = $payload['pull_request']['diff_url']; - $content = file_get_contents($url); + global $github_diff; + if ($github_diff === null) { + //go to the diff url + $url = $payload['pull_request']['diff_url']; + $github_diff = file_get_contents($url); + } //find things in the _maps/map_files tree //e.g. diff --git a/_maps/map_files/Cerestation/cerestation.dmm b/_maps/map_files/Cerestation/cerestation.dmm - return $content !== FALSE && strpos($content, 'diff --git a/' . $tree) !== FALSE; + return $github_diff !== FALSE && strpos($github_diff, 'diff --git a/' . $tree) !== FALSE; } function checkchangelog($payload, $merge = false, $compile = true) {