Performance Dashboard should be compatible with PHP 7.
authordewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Aug 2017 23:04:19 +0000 (23:04 +0000)
committerdewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Aug 2017 23:04:19 +0000 (23:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=175813

Reviewed by Ryosuke Niwa.

Use `file_get_contents('php://input')` instead of '$HTTP_RAW_POST_DATA'.
Update test harness script to load right php module in httpd.

* ReadMe.md: JSON example format fix.
* public/api/report-commits.php: Stop using '$HTTP_RAW_POST_DATA'.
* public/api/report.php: Stop using '$HTTP_RAW_POST_DATA'.
* public/api/update-triggerable.php: Stop using '$HTTP_RAW_POST_DATA'.
* public/include/json-header.php: Stop using '$HTTP_RAW_POST_DATA'.
* public/include/report-processor.php: Stop using '$HTTP_RAW_POST_DATA'.
* server-tests/resources/test-server.conf: Load php5 or php7 module conditionally.
* server-tests/resources/test-server.js: Pass PHP version info while launching httpd.
(TestServer.prototype._startApache):
* tools/remote-cache-server.py: Pass PHP version info while launching httpd.
(start_httpd):
* tools/remote-server-relay.conf: Load php5 or php7 module conditionally.
* tools/sync-buildbot.js:
(syncLoop.const.makeTriggerable):
(syncLoop):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221053 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/ReadMe.md
Websites/perf.webkit.org/public/api/report-commits.php
Websites/perf.webkit.org/public/api/report.php
Websites/perf.webkit.org/public/api/update-triggerable.php
Websites/perf.webkit.org/public/include/json-header.php
Websites/perf.webkit.org/public/include/report-processor.php
Websites/perf.webkit.org/server-tests/resources/test-server.conf
Websites/perf.webkit.org/server-tests/resources/test-server.js
Websites/perf.webkit.org/tools/remote-cache-server.py
Websites/perf.webkit.org/tools/remote-server-relay.conf
Websites/perf.webkit.org/tools/sync-buildbot.js

index 324d7a8..5c52a46 100644 (file)
@@ -1,3 +1,29 @@
+2017-08-21  Dewei Zhu  <dewei_zhu@apple.com>
+
+        Performance Dashboard should be compatible with PHP 7.
+        https://bugs.webkit.org/show_bug.cgi?id=175813
+
+        Reviewed by Ryosuke Niwa.
+
+        Use `file_get_contents('php://input')` instead of '$HTTP_RAW_POST_DATA'.
+        Update test harness script to load right php module in httpd.
+
+        * ReadMe.md: JSON example format fix.
+        * public/api/report-commits.php: Stop using '$HTTP_RAW_POST_DATA'.
+        * public/api/report.php: Stop using '$HTTP_RAW_POST_DATA'.
+        * public/api/update-triggerable.php: Stop using '$HTTP_RAW_POST_DATA'.
+        * public/include/json-header.php: Stop using '$HTTP_RAW_POST_DATA'.
+        * public/include/report-processor.php: Stop using '$HTTP_RAW_POST_DATA'.
+        * server-tests/resources/test-server.conf: Load php5 or php7 module conditionally.
+        * server-tests/resources/test-server.js: Pass PHP version info while launching httpd.
+        (TestServer.prototype._startApache):
+        * tools/remote-cache-server.py: Pass PHP version info while launching httpd.
+        (start_httpd):
+        * tools/remote-server-relay.conf: Load php5 or php7 module conditionally.
+        * tools/sync-buildbot.js:
+        (syncLoop.const.makeTriggerable):
+        (syncLoop):
+
 2017-08-17  Ryosuke Niwa  <rniwa@webkit.org>
 
         Number each section in ReadMe.md and add more clarifications
index 91eaf14..6646fb0 100644 (file)
@@ -275,7 +275,7 @@ The test also reports `FrameRate` but this metric is measured only for the entir
                 "FrameRate": {
                     "current": [31, 24, 29]
                 }
-            }
+            },
             "tests": {
                 "webkit.org": {
                     "metrics": {
@@ -292,9 +292,9 @@ The test also reports `FrameRate` but this metric is measured only for the entir
                         }
                     },
                     "url": "https://www.w3.org/"
-                },
-            },
-        },
+                }
+            }
+        }
     }
 }]
 ```
index dc2ed8d..559b41b 100644 (file)
@@ -99,6 +99,6 @@ function insert_commit($db, $commit_info, $repository_id, $owner_commit_id)
     return $inserted_commit_id;
 }
 
-main($HTTP_RAW_POST_DATA);
+main(file_get_contents('php://input'));
 
 ?>
index 76fb6bf..3d7204d 100644 (file)
@@ -50,6 +50,6 @@ function main($post_data) {
     exit_with_success();
 }
 
-main($HTTP_RAW_POST_DATA);
+main(file_get_contents('php://input'));
 
 ?>
index d8f93e7..6d64f6a 100644 (file)
@@ -142,6 +142,6 @@ function validate_repository_groups($db, &$repository_groups)
     }
 }
 
-main($HTTP_RAW_POST_DATA);
+main(file_get_contents('php://input'));
 
 ?>
index 9795c65..5f8cf14 100644 (file)
@@ -95,7 +95,6 @@ function require_existence_of($array, $list_of_arguments, $prefix = '') {
 }
 
 function ensure_privileged_api_data() {
-    global $HTTP_RAW_POST_DATA;
 
     if (config('maintenanceMode'))
         exit_with_error('InMaintenanceMode');
@@ -103,10 +102,7 @@ function ensure_privileged_api_data() {
     if ($_SERVER['REQUEST_METHOD'] != 'POST')
         exit_with_error('InvalidRequestMethod');
 
-    if (!isset($HTTP_RAW_POST_DATA))
-        exit_with_error('InvalidRequestContent');
-
-    $data = json_decode($HTTP_RAW_POST_DATA, true);
+    $data = json_decode(file_get_contents('php://input'), true);
 
     if ($data === NULL)
         exit_with_error('InvalidRequestContent');
index 7a17228..2fc2f5c 100644 (file)
@@ -166,7 +166,7 @@ class ReportProcessor {
                 array('repository' => $repository_id, 'revision' => $revision_data['revision']), $commit_data, '*');
             if (!$commit_row)
                 $this->exit_with_error('FailedToRecordCommit', $commit_data);
-            if ($commit_data['time'] && abs($commit_row['commit_time'] - $commit_data['time']) > 1.0)
+            if ($commit_data['time'] && abs(floatval($commit_row['commit_time']) - floatval($commit_data['time'])) > 1.0)
                 $this->exit_with_error('MismatchingCommitTime', array('existing' => $commit_row, 'new' => $commit_data));
 
             if (!$this->db->select_or_insert_row('build_commits', null,
index 7ac2973..936b4f4 100644 (file)
@@ -16,7 +16,14 @@ LoadModule negotiation_module libexec/apache2/mod_negotiation.so
 LoadModule dir_module libexec/apache2/mod_dir.so
 LoadModule alias_module libexec/apache2/mod_alias.so
 LoadModule rewrite_module libexec/apache2/mod_rewrite.so
-LoadModule php5_module libexec/apache2/libphp5.so
+
+<IfDefine PHP5>
+    LoadModule php5_module libexec/apache2/libphp5.so
+</IfDefine>
+
+<IfDefine PHP7>
+    LoadModule php7_module libexec/apache2/libphp7.so
+</IfDefine>
 
 <Directory />
     Options Indexes FollowSymLinks MultiViews
@@ -57,4 +64,12 @@ LogLevel warn
     php_value post_max_size 5M
 </IfModule>
 
+<IfModule php7_module>
+    AddType application/x-httpd-php .php
+    AddType application/x-httpd-php-source .phps
+
+    php_value upload_max_filesize 5M
+    php_value post_max_size 5M
+</IfModule>
+
 Include /private/etc/apache2/extra/httpd-mpm.conf
index 988285d..b0d3f68 100644 (file)
@@ -170,6 +170,7 @@ class TestServer {
         let port = Config.value('testServer.port');
         let errorLog = Config.path('testServer.httpdErrorLog');
         let mutexFile = Config.path('testServer.httpdMutexDir');
+        let phpVersion = childProcess.execFileSync('php', ['-v'], {stdio: ['pipe', 'pipe', 'ignore']}).toString().includes('PHP 5') ? 'PHP5' : 'PHP7';
 
         if (!fs.existsSync(mutexFile))
             fs.mkdirSync(mutexFile, 0o755);
@@ -181,7 +182,8 @@ class TestServer {
             '-c', `PidFile ${pidFile}`,
             '-c', `ErrorLog ${errorLog}`,
             '-c', `Mutex file:${mutexFile}`,
-            '-c', `DocumentRoot ${Config.serverRoot()}`];
+            '-c', `DocumentRoot ${Config.serverRoot()}`,
+            '-D', phpVersion];
 
         if (this._shouldLog)
             console.log(args);
@@ -192,7 +194,7 @@ class TestServer {
             scheme: 'http',
             host: 'localhost',
             port: port,
-        }
+        };
         this._pidWaitStart = Date.now();
         this._pidFile = pidFile;
 
index 79cfa3c..747f479 100755 (executable)
@@ -37,6 +37,8 @@ def start_httpd(remote_server_config):
     httpd_pid_file = abspath_from_root(remote_server_config['httpdPID'])
     httpd_error_log_file = abspath_from_root(remote_server_config['httpdErrorLog'])
     httpd_mutex_dir = abspath_from_root(remote_server_config['httpdMutexDir'])
+    version_info = subprocess.check_output(['php', '-v'], stderr=subprocess.PIPE)
+    php_version = 'PHP5' if 'PHP 5' in version_info else 'PHP7'
 
     if not os.path.isdir(httpd_mutex_dir):
         os.makedirs(httpd_mutex_dir)
@@ -50,8 +52,8 @@ def start_httpd(remote_server_config):
         '-c', 'PidFile ' + httpd_pid_file,
         '-c', 'Mutex file:' + httpd_mutex_dir,
         '-c', 'DocumentRoot ' + doc_root,
-        '-c', 'ErrorLog ' + httpd_error_log_file])
-
+        '-c', 'ErrorLog ' + httpd_error_log_file,
+        '-D', php_version])
 
 def stop_httpd(remote_server_config):
     httpd_pid_file = abspath_from_root(remote_server_config['httpdPID'])
index 0cf569a..2762e26 100644 (file)
@@ -16,7 +16,14 @@ LoadModule negotiation_module libexec/apache2/mod_negotiation.so
 LoadModule dir_module libexec/apache2/mod_dir.so
 LoadModule alias_module libexec/apache2/mod_alias.so
 LoadModule rewrite_module libexec/apache2/mod_rewrite.so
-LoadModule php5_module libexec/apache2/libphp5.so
+
+<IfDefine PHP5>
+    LoadModule php5_module libexec/apache2/libphp5.so
+</IfDefine>
+
+<IfDefine PHP7>
+    LoadModule php7_module libexec/apache2/libphp7.so
+</IfDefine>
 
 <Directory />
     Options Indexes FollowSymLinks MultiViews
@@ -58,4 +65,9 @@ RewriteRule "/api/(.*)$" "/admin/fetch-from-remote.php/api/$1"
        AddType application/x-httpd-php-source .phps
 </IfModule>
 
+<IfModule php7_module>
+       AddType application/x-httpd-php .php
+       AddType application/x-httpd-php-source .phps
+</IfModule>
+
 Include /private/etc/apache2/extra/httpd-mpm.conf
index 42e9298..34aa6ea 100755 (executable)
@@ -32,7 +32,7 @@ function syncLoop(options)
 
     const makeTriggerable = function () {
         return new BuildbotTriggerable(buildbotConfig, global.RemoteAPI, buildbotRemote, serverConfig.slave, console)
-    }
+    };
 
     Manifest.fetch().then(() => {
         return makeTriggerable().updateTriggerable();