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:
authordiosmosis <benaka@piwik.pro>2015-09-08 01:20:09 +0300
committerdiosmosis <benaka@piwik.pro>2015-09-10 23:35:21 +0300
commit3b6066c77aeaefd59ea7f1b356f8f99ca6f6df70 (patch)
tree6b683f71400e4650a0df3711345ac517e56889b4 /plugins/API
parenta94b3d49cef47b6e5b338ed4b8a83f3318fb1ffe (diff)
Check for valid data in RowEvolution API to avoid unexpected fatal errors.
Diffstat (limited to 'plugins/API')
-rw-r--r--plugins/API/RowEvolution.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/plugins/API/RowEvolution.php b/plugins/API/RowEvolution.php
index 6e31a13317..c708608089 100644
--- a/plugins/API/RowEvolution.php
+++ b/plugins/API/RowEvolution.php
@@ -360,9 +360,16 @@ class RowEvolution
unset($metadata['logos']);
$subDataTables = $dataTable->getDataTables();
+ if (empty($subDataTables)) {
+ throw new \Exception("Unexpected state: row evolution API call returned empty DataTable\\Map.");
+ }
+
$firstDataTable = reset($subDataTables);
+ $this->checkDataTableInstance($firstDataTable);
$firstDataTableRow = $firstDataTable->getFirstRow();
+
$lastDataTable = end($subDataTables);
+ $this->checkDataTableInstance($lastDataTable);
$lastDataTableRow = $lastDataTable->getFirstRow();
// Process min/max values
@@ -533,4 +540,11 @@ class RowEvolution
$label = SafeDecodeLabel::decodeLabelSafe($label);
return $label;
}
+
+ private function checkDataTableInstance($lastDataTable)
+ {
+ if (!($lastDataTable instanceof DataTable)) {
+ throw new \Exception("Unexpected state: row evolution returned DataTable\\Map w/ incorrect child table type: " . get_class($lastDataTable));
+ }
+ }
}