Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Zhang <peter@innocraft.com>2022-02-10 13:40:38 +0300
committerGitHub <noreply@github.com>2022-02-10 13:40:38 +0300
commita36b45a3764cd28303d2ce27c600c7d6f5a5ed20 (patch)
tree252e6288c79d473dc8136bc7ccd8aa941044b058
parentc0a1767561ddc7fa85b11b713febdb027c3323cf (diff)
[hotfix]php8.0 key on empty object throw error (#18687)
* Update API.php update a condition * Update API.php throw exception when column not find * built vue files * Update plugins/ImageGraph/API.php Co-authored-by: Stefan Giehl <stefan@matomo.org> * Update API.php update typo Co-authored-by: peterhashair <peterhashair@users.noreply.github.com> Co-authored-by: Stefan Giehl <stefan@matomo.org>
-rw-r--r--plugins/ImageGraph/API.php14
1 files changed, 12 insertions, 2 deletions
diff --git a/plugins/ImageGraph/API.php b/plugins/ImageGraph/API.php
index 0a4863ecc8..d326ef4230 100644
--- a/plugins/ImageGraph/API.php
+++ b/plugins/ImageGraph/API.php
@@ -238,8 +238,18 @@ class API extends \Piwik\Plugin\API
$ordinateColumns = array();
if (empty($columns)) {
- $ordinateColumns[] =
- empty($reportColumns[self::DEFAULT_ORDINATE_METRIC]) ? key($metadata['metrics']) : self::DEFAULT_ORDINATE_METRIC;
+ if (!empty($reportColumns[self::DEFAULT_ORDINATE_METRIC])) {
+ $ordinateColumns[] = self::DEFAULT_ORDINATE_METRIC;
+ } else if (!empty($metadata['metrics'])) {
+ $ordinateColumns[] = key($metadata['metrics']);
+ } else {
+ throw new Exception(
+ Piwik::translate(
+ 'ImageGraph_ColumnOrdinateMissing',
+ array(self::DEFAULT_ORDINATE_METRIC, implode(',', array_keys($reportColumns)))
+ )
+ );
+ }
} else {
$ordinateColumns = explode(',', $columns);
foreach ($ordinateColumns as $column) {