Skip to content

Commit

Permalink
Fixes #3898, fix error that occurs when multi row evolution is called…
Browse files Browse the repository at this point in the history
… w/o labels for periods w/ no data.
  • Loading branch information
diosmosis committed Apr 17, 2013
1 parent c91a603 commit befb48d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
7 changes: 5 additions & 2 deletions plugins/API/API.php
Expand Up @@ -1197,7 +1197,7 @@ public function getRowEvolution($idSite, $period, $date, $apiModule, $apiAction,
}
}

if (count($labels) > 1) {
if (count($labels) != 1) {
$data = $this->getMultiRowEvolution(
$dataTable,
$idSite,
Expand Down Expand Up @@ -1538,7 +1538,10 @@ private function getMultiRowEvolution($dataTable, $idSite, $period, $date, $apiM
}

$newTable = $table->getEmptyClone();
$newTable->addRow($newRow);
if (!empty($labels)) { // only add a row if the row has data (no labels === no data)
$newTable->addRow($newRow);
}

$dataTableMulti->addTable($newTable, $tableLabel);
}

Expand Down
15 changes: 15 additions & 0 deletions tests/PHPUnit/Integration/RowEvolutionTest.php
Expand Up @@ -171,6 +171,21 @@ public function getApiForTesting()
)
));

// test multi row evolution when there is no data
$return[] = array('API.getRowEvolution', array(
'testSuffix' => '_multiWithNoData',
'periods' => 'day',
'idSite' => $idSite,
'date' => $today,
'otherRequestParameters' => array(
'date' => '2010-04-01,2010-04-06',
'period' => 'day',
'apiModule' => 'Referers',
'apiAction' => 'getWebsites',
// no label
)
));

// (non-rowevolution test) test flattener w/ search engines to make sure
// queued filters are not applied twice
$return[] = array('Referers.getSearchEngines', array(
Expand Down

0 comments on commit befb48d

Please sign in to comment.