diff --git a/vendor/illuminate/support/helpers.php b/vendor/illuminate/support/helpers.php index 0b82fe7693..45c5ca6446 100755 --- a/vendor/illuminate/support/helpers.php +++ b/vendor/illuminate/support/helpers.php @@ -115,6 +115,10 @@ function e($value, $doubleEncode = true) return $value->toHtml(); } + if (is_array($value)) { + $value = json_encode($value); + } + return htmlspecialchars($value ?? '', ENT_QUOTES, 'UTF-8', $doubleEncode); } } diff --git a/vendor/illuminate/view/Factory.php b/vendor/illuminate/view/Factory.php index de431f77e4..f760988e13 100755 --- a/vendor/illuminate/view/Factory.php +++ b/vendor/illuminate/view/Factory.php @@ -219,6 +219,9 @@ public function renderEach($view, $data, $iterator, $empty = 'raw|') // If is actually data in the array, we will loop through the data and append // an instance of the partial view to the final result HTML passing in the // iterated value of this data array, allowing the views to access them. + if (is_object($data)) { + $data = (array)$data; + } if (count($data) > 0) { foreach ($data as $key => $value) { $result .= $this->make( diff --git a/www/common.inc b/www/common.inc index 5853633155..71e48d48cb 100644 --- a/www/common.inc +++ b/www/common.inc @@ -518,7 +518,9 @@ if (strlen($id)) { if ($test['testinfo']) { $testTestInfo = $test['testinfo']; if (!empty($testTestInfo['metadata'])) { - $metaInfo = json_decode($testTestInfo['metadata'], true); + if (!is_array($testTestInfo['metadata'])) { + $metaInfo = json_decode($testTestInfo['metadata'], true); + } if ($metaInfo['experiment'] && $metaInfo['experiment']['control'] === false) { $experiment = true; diff --git a/www/include/RunResultHtmlTable.php b/www/include/RunResultHtmlTable.php index ae5187bd6a..f73a27affd 100644 --- a/www/include/RunResultHtmlTable.php +++ b/www/include/RunResultHtmlTable.php @@ -80,7 +80,7 @@ public function __construct($testInfo, $runResults, $rvRunResults = null, $useSh // disable env impact if not collected - if (count($this->runResults->getStepResult(1)->getMetric(self::COL_ENV_IMP)) === 0) { + if ($this->runResults->getStepResult(1)->getMetric(self::COL_ENV_IMP) && count($this->runResults->getStepResult(1)->getMetric(self::COL_ENV_IMP)) === 0) { $this->enabledColumns[self::COL_ENV_IMP] = false; } @@ -568,9 +568,12 @@ private function _createRow($stepResult, $row, $repeatMetricLabels = false) ['custom' => $customMetrics], (new Timings($this->runResults))->getAllForStep($stepNum), ); - $out .= view('partials.timings', [ - 'data' => $timingsAndMetrics, - ]); + try { + $out .= view('partials.timings', [ + 'data' => $timingsAndMetrics, + ]); + } catch (\Exception $e) { + } } } return $out; diff --git a/www/lighthouse.php b/www/lighthouse.php index b2a52821e2..1b23a0c4fa 100644 --- a/www/lighthouse.php +++ b/www/lighthouse.php @@ -32,38 +32,32 @@ $filePath = "$testPath/$file"; } if (is_file($filePath)) { - // if &f=lh-viewer is in the url, we'll show the lighthouse viewer html as it exports - if (isset($_REQUEST['f']) && $_REQUEST['f'] == 'lh-viewer') { - $ok = true; + $ok = true; - // Cache for a year - header('Last-Modified: ' . gmdate('r')); - header('Cache-Control: public,max-age=31536000', true); - header('Content-type: text/html'); - $lighthouseTrace = "$testPath/lighthouse_trace.json"; - if (gz_is_file($lighthouseTrace)) { - // Add the HTML to view/download the trace and timelines to the raw html - $html = gz_file_get_contents($filePath); - $insert = '
'; - $insert .= "

Timeline from test: Download or View   -   "; - $trace_url = urlencode(getUrlProtocol() . '://' . $_SERVER['HTTP_HOST'] . "/getgzip.php?test=$id&file=lighthouse_trace.json"); - $insert .= "Trace from test: Download or View

"; - $insert .= "
"; - $insert .= '
'; - $insert_pos = strpos($html, ''); - if ($insert_pos !== false) { - echo substr($html, 0, $insert_pos); - echo $insert; - echo substr($html, $insert_pos); - } else { - echo $html; - } + // Cache for a year + header('Last-Modified: ' . gmdate('r')); + header('Cache-Control: public,max-age=31536000', true); + header('Content-type: text/html'); + $lighthouseTrace = "$testPath/lighthouse_trace.json"; + if (gz_is_file($lighthouseTrace)) { + // Add the HTML to view/download the trace and timelines to the raw html + $html = gz_file_get_contents($filePath); + $insert = '
'; + $insert .= "

Timeline from test: Download or View   -   "; + $trace_url = urlencode(getUrlProtocol() . '://' . $_SERVER['HTTP_HOST'] . "/getgzip.php?test=$id&file=lighthouse_trace.json"); + $insert .= "Trace from test: Download or View

"; + $insert .= "
"; + $insert .= '
'; + $insert_pos = strpos($html, ''); + if ($insert_pos !== false) { + echo substr($html, 0, $insert_pos); + echo $insert; + echo substr($html, $insert_pos); } else { - gz_readfile_chunked($filePath); + echo $html; } } else { - // show HTML (Blade) page - require_once INCLUDES_PATH . '/include/lighthouse-page.inc.php'; + gz_readfile_chunked($filePath); } } else { $info = GetTestInfo($testPath);