diff options
author | Zoltan Flamis <zoltan@hey.com> | 2021-03-11 11:02:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-11 11:02:32 +0300 |
commit | e3e913252329f9e26833c4f68980f288735fc770 (patch) | |
tree | 313d1404634c23e536d9ead35004c67bbf86ef4e /plugins/ImageGraph | |
parent | 23566683edea9bd32e1a49ac7f4892919102a87a (diff) |
Throw invalid dimension exception during rendering graph with wrong height/width values (#17320)
* wip
* invalid dimension exception
* re-throw excpetion
Diffstat (limited to 'plugins/ImageGraph')
-rw-r--r-- | plugins/ImageGraph/API.php | 3 | ||||
-rw-r--r-- | plugins/ImageGraph/StaticGraph/GridGraph.php | 5 |
2 files changed, 8 insertions, 0 deletions
diff --git a/plugins/ImageGraph/API.php b/plugins/ImageGraph/API.php index 4402b14bfd..0a4863ecc8 100644 --- a/plugins/ImageGraph/API.php +++ b/plugins/ImageGraph/API.php @@ -14,6 +14,7 @@ use Piwik\Archive\DataTableFactory; use Piwik\Common; use Piwik\Container\StaticContainer; use Piwik\DataTable\Map; +use Piwik\Exception\InvalidDimensionException; use Piwik\Filesystem; use Piwik\Period; use Piwik\Piwik; @@ -493,6 +494,8 @@ class API extends \Piwik\Plugin\API // render graph $graph->renderGraph(); + } catch (InvalidDimensionException $e) { + throw $e; } catch (\Exception $e) { $graph = new \Piwik\Plugins\ImageGraph\StaticGraph\Exception(); diff --git a/plugins/ImageGraph/StaticGraph/GridGraph.php b/plugins/ImageGraph/StaticGraph/GridGraph.php index 9a95577892..a558f76332 100644 --- a/plugins/ImageGraph/StaticGraph/GridGraph.php +++ b/plugins/ImageGraph/StaticGraph/GridGraph.php @@ -8,6 +8,7 @@ */ namespace Piwik\Plugins\ImageGraph\StaticGraph; +use Piwik\Exception\InvalidDimensionException; use Piwik\Plugins\ImageGraph\StaticGraph; /** @@ -145,6 +146,10 @@ abstract class GridGraph extends StaticGraph } } + if (($bottomRightYValue - $topLeftYValue) <= ($ordinateAxisLength / 2)) { + throw new InvalidDimensionException('Error: the graph dimension is not valid. Please try larger width and height values or use 0 for default values.'); + } + $gridColor = $this->gridColor; $this->pImage->drawScale( array( |