Skip to content

Commit

Permalink
Fixed unhandled errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pmeenan committed Dec 15, 2023
1 parent 0fc3777 commit f8460a1
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 33 deletions.
4 changes: 4 additions & 0 deletions vendor/illuminate/support/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
3 changes: 3 additions & 0 deletions vendor/illuminate/view/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 3 additions & 1 deletion www/common.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
11 changes: 7 additions & 4 deletions www/include/RunResultHtmlTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down
50 changes: 22 additions & 28 deletions www/lighthouse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<div style="text-align: center; line-height: 2em;"><span>';
$insert .= "<p>Timeline from test: <a href=\"/getTimeline.php?test=$id&run=lighthouse\">Download</a> or <a href=\"/chrome/timeline.php?test=$id&run=lighthouse\" target=\"_blank\" rel=\"noopener\">View</a> &nbsp; - &nbsp; ";
$trace_url = urlencode(getUrlProtocol() . '://' . $_SERVER['HTTP_HOST'] . "/getgzip.php?test=$id&file=lighthouse_trace.json");
$insert .= "Trace from test: <a href=\"/getgzip.php?test=$id&file=lighthouse_trace.json\">Download</a> or <a href=\"/chrome/perfetto/index.html#!/viewer?url=$trace_url\" target=\"_blank\" rel=\"noopener\">View</a></p>";
$insert .= "</span>";
$insert .= '</div>';
$insert_pos = strpos($html, '</footer>');
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 = '<div style="text-align: center; line-height: 2em;"><span>';
$insert .= "<p>Timeline from test: <a href=\"/getTimeline.php?test=$id&run=lighthouse\">Download</a> or <a href=\"/chrome/timeline.php?test=$id&run=lighthouse\" target=\"_blank\" rel=\"noopener\">View</a> &nbsp; - &nbsp; ";
$trace_url = urlencode(getUrlProtocol() . '://' . $_SERVER['HTTP_HOST'] . "/getgzip.php?test=$id&file=lighthouse_trace.json");
$insert .= "Trace from test: <a href=\"/getgzip.php?test=$id&file=lighthouse_trace.json\">Download</a> or <a href=\"/chrome/perfetto/index.html#!/viewer?url=$trace_url\" target=\"_blank\" rel=\"noopener\">View</a></p>";
$insert .= "</span>";
$insert .= '</div>';
$insert_pos = strpos($html, '</footer>');
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);
Expand Down

0 comments on commit f8460a1

Please sign in to comment.