Skip to content

Commit

Permalink
refs #3158 row evolution
Browse files Browse the repository at this point in the history
 * bug fix: the export beneath row evolution graphs didn't work. the reason was that it passed an expanded=1 and a label parameter to the API. solution: ignore expanded parameter if label parameter is set.
 * small code improvements
  • Loading branch information
timo-bes committed Apr 8, 2013
1 parent 91e38e4 commit 221b74d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
8 changes: 2 additions & 6 deletions core/API/DataTableManipulator/LabelFilter.php
Expand Up @@ -17,11 +17,6 @@
* The labels passed to this class should be urlencoded.
* Some reports use recursive labels (e.g. action reports). Use > to join them.
*
* This filter does not work when expanded=1 is set because it is designed to load
* only the subtables on the path, not all existing subtables (which would happen with
* expanded=1). Also, the aim of this filter is to return only the row matching the
* label. With expanded=1, the subtables of the matching row would be returned as well.
*
* @package Piwik
* @subpackage Piwik_API
*/
Expand Down Expand Up @@ -69,6 +64,7 @@ private function doFilterRecursiveDescend($labelParts, $dataTable)
// search for the first part of the tree search
$labelPart = array_shift($labelParts);

$row = false;
foreach ($this->getLabelVariations($labelPart) as $labelPart) {
$row = $dataTable->getRowFromLabel($labelPart);
if ($row !== false) {
Expand Down Expand Up @@ -141,7 +137,7 @@ private function getLabelVariations($label)
protected function manipulateDataTable($dataTable)
{
$result = $dataTable->getEmptyClone();
foreach ($this->labels as $labelIdx => $label) {
foreach ($this->labels as $label) {
$row = null;
foreach ($this->getLabelVariations($label) as $labelVariation) {
$labelVariation = explode(self::SEPARATOR_RECURSIVE_LABEL, $labelVariation);
Expand Down
17 changes: 17 additions & 0 deletions core/API/Request.php
Expand Up @@ -85,6 +85,23 @@ static public function getRequestArrayFromString($request)
function __construct($request = null)
{
$this->request = self::getRequestArrayFromString($request);
$this->sanitizeRequest();
}

/**
* Make sure that the request contains no logical errors
*/
private function sanitizeRequest()
{
// The label filter does not work with expanded=1 because the data table IDs have a different meaning
// depending on whether the table has been loaded yet. expanded=1 causes all tables to be loaded, which
// is why the label filter can't descend when a recursive label has been requested.
// To fix this, we remove the expanded parameter if a label parameter is set.
if (isset($this->request['label']) && !empty($this->request['label'])
&& isset($this->request['expanded']) && $this->request['expanded']
) {
unset($this->request['expanded']);
}
}

/**
Expand Down

0 comments on commit 221b74d

Please sign in to comment.