Skip to content

Commit

Permalink
Handle change to output of chromium 109
Browse files Browse the repository at this point in the history
Looks like the console output change somewhere between chromium 99 and 109.
This code handles both scenarios
  • Loading branch information
jpwhite4 committed Jan 30, 2023
1 parent 63aea89 commit 80f2278
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions libraries/charting.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,22 @@ function getSvgFromChromium($html, $width, $height){

@unlink($tmpHtmlFile);

$result = json_decode(substr($out, 4, -6), true);
$jsondata = json_decode(substr($out, 4, -6), true);

$chartSvg = null;
if (isset($jsondata['result']) && isset($jsondata['result']['value'])) {
// chrome headless 99
$chartSvg = $jsondata['result']['value'];
} elseif (isset($jsondata['result']) && isset($jsondata['result']['result']) && isset($jsondata['result']['result']['value'])) {
// chrome headless 109
$chartSvg = $jsondata['result']['result']['value'];
}

if ($result === null || !isset($result['result']) || !isset($result['result']['value'])) {
if ($chartSvg === null) {
throw new \Exception('Error executing command: "'. $command . '". Details: ' . $return_value . " " . $out . ' Errors: ' . $err);
}

return $result['result']['value'];
return $chartSvg;
}

/**
Expand Down

0 comments on commit 80f2278

Please # to comment.