diff --git a/plugins/API/API.php b/plugins/API/API.php index 8bceb2cbe6d..23cf8147683 100644 --- a/plugins/API/API.php +++ b/plugins/API/API.php @@ -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, @@ -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); } diff --git a/tests/PHPUnit/Integration/RowEvolutionTest.php b/tests/PHPUnit/Integration/RowEvolutionTest.php index 964cad67f79..7ef6d849d36 100755 --- a/tests/PHPUnit/Integration/RowEvolutionTest.php +++ b/tests/PHPUnit/Integration/RowEvolutionTest.php @@ -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(