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:
authorStefan Giehl <stefan@piwik.org>2018-03-27 01:48:33 +0300
committerMatthieu Aubry <mattab@users.noreply.github.com>2018-03-27 01:48:33 +0300
commitd21787d7b6eb3c1b804d7cbe29492e18e98de890 (patch)
tree8ad2fd617e14da04dd7965c4051194d569bca165 /plugins/API
parent27c559bb87674ce6f6f16f5a296691d27eba617e (diff)
Ensure number of rows and row metadata equals in processed reports (#12650)
* Ensure number of rows and row metadata equals so they can be matched by ID * reset $rowsMetadata to empty DataTable if no row had metadata * update test files
Diffstat (limited to 'plugins/API')
-rw-r--r--plugins/API/ProcessedReport.php15
1 files changed, 12 insertions, 3 deletions
diff --git a/plugins/API/ProcessedReport.php b/plugins/API/ProcessedReport.php
index 1cd327c8c7..6caac672c3 100644
--- a/plugins/API/ProcessedReport.php
+++ b/plugins/API/ProcessedReport.php
@@ -617,6 +617,8 @@ class ProcessedReport
$formatter = new Formatter();
+ $hasNonEmptyRowData = false;
+
foreach ($simpleDataTable->getRows() as $row) {
$rowMetrics = $row->getColumns();
@@ -668,10 +670,12 @@ class ProcessedReport
$rowMetadata = $row->getMetadata();
$idSubDataTable = $row->getIdSubDataTable();
- // Create a row metadata only if there are metadata to insert
+ // always add a metadata row - even if empty, so the number of rows and metadata are equal and can be matched directly
+ $metadataRow = new Row();
+ $rowsMetadata->addRow($metadataRow);
+
if (count($rowMetadata) > 0 || !is_null($idSubDataTable)) {
- $metadataRow = new Row();
- $rowsMetadata->addRow($metadataRow);
+ $hasNonEmptyRowData = true;
foreach ($rowMetadata as $metadataKey => $metadataValue) {
$metadataRow->addColumn($metadataKey, $metadataValue);
@@ -684,6 +688,11 @@ class ProcessedReport
}
}
+ // reset $rowsMetadata to empty DataTable if no row had metadata
+ if ($hasNonEmptyRowData === false) {
+ $rowsMetadata = new DataTable();
+ }
+
return array(
$enhancedDataTable,
$rowsMetadata