Skip to content

Commit

Permalink
refs matomo-org#4706 prevent sumRowArray exception in Live API
Browse files Browse the repository at this point in the history
  • Loading branch information
tsteur committed May 13, 2014
1 parent f47fb23 commit b4d1ff0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions plugins/Live/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,9 @@ private function addFilterToCleanVisitors(DataTable $dataTable, $idSite, $flat =
$timezone = $website->getTimezone();
$currencies = APISitesManager::getInstance()->getCurrencySymbols();

// live api is not summable, prevents errors like "Unexpected ECommerce status value"
$table->deleteRow(DataTable::ID_SUMMARY_ROW);

foreach ($table->getRows() as $visitorDetailRow) {
$visitorDetailsArray = Visitor::cleanVisitorDetails($visitorDetailRow->getColumns());

Expand Down Expand Up @@ -686,6 +689,15 @@ private function loadLastVisitorDetailsFromDatabase($idSite, $period, $date, $se

$dataTable = new DataTable();
$dataTable->addRowsFromSimpleArray($data);
// $dataTable->disableFilter('Truncate');

if (!empty($data[0])) {
$columnsToNotAggregate = array_map(function () {
return 'skip';
}, $data[0]);

$dataTable->setMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME, $columnsToNotAggregate);
}

return $dataTable;
}
Expand Down

0 comments on commit b4d1ff0

Please sign in to comment.