Upstream changes to json-shared.php from the perf dashboard
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Jan 2014 06:12:57 +0000 (06:12 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Jan 2014 06:12:57 +0000 (06:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=127544

Reviewed by Joseph Pecoraro.

json-shared.php originated from the perf dashboard.
Upstream changes made to the version in the perf. dashboard so that two apps could share the same code.

* public/include/json-shared.php:
(exit_with_error):
(echo_success):
(exit_with_success):
(set_exit_detail):
(merge_additional_details):

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

Websites/test-results/ChangeLog
Websites/test-results/public/include/json-shared.php

index 86fe51b..fb215c5 100644 (file)
@@ -1,3 +1,20 @@
+2014-01-23  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Upstream changes to json-shared.php from the perf dashboard
+        https://bugs.webkit.org/show_bug.cgi?id=127544
+
+        Reviewed by Joseph Pecoraro.
+
+        json-shared.php originated from the perf dashboard.
+        Upstream changes made to the version in the perf. dashboard so that two apps could share the same code.
+
+        * public/include/json-shared.php:
+        (exit_with_error):
+        (echo_success):
+        (exit_with_success):
+        (set_exit_detail):
+        (merge_additional_details):
+
 2013-11-06  Ryosuke Niwa  <rniwa@webkit.org>
 
         New flakiness dashboard should generate JSON in the background process
index e91903c..fcd2598 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-require_once('../include/db.php');
+require_once('db.php');
 
 header('Content-type: application/json');
 $maxage = config('jsonCacheMaxAge');
@@ -9,12 +9,16 @@ header("Cache-Control: maxage=$maxage");
 
 function exit_with_error($status, $details = array()) {
     $details['status'] = $status;
+    merge_additional_details($details);
+
     echo json_encode($details);
     exit(1);
 }
 
 function echo_success($details = array()) {
     $details['status'] = 'OK';
+    merge_additional_details($details);
+
     echo json_encode($details);
 }
 
@@ -23,6 +27,21 @@ function exit_with_success($details = array()) {
     exit(0);
 }
 
+$additional_exit_details = array();
+
+function set_exit_detail($name, $value) {
+    global $additional_exit_details;
+    $additional_exit_details[$name] = $value;
+}
+
+function merge_additional_details(&$details) {
+    global $additional_exit_details;
+    foreach ($additional_exit_details as $name => $value) {
+        if (!array_key_exists($name, $details))
+            $details[$name] = $value;
+    }
+}
+
 function connect() {
     $db = new Database;
     if (!$db->connect())