Skip to content

Commit

Permalink
Merge pull request #1688 from jpwhite4/chrome_incompatible
Browse files Browse the repository at this point in the history
Handle change to output of chromium 109
  • Loading branch information
jpwhite4 authored Jan 30, 2023
2 parents 63aea89 + 80f2278 commit b70b7c8
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 b70b7c8

Please # to comment.