Skip to content
Extraits de code Groupes Projets
Valider 3b962d95 rédigé par Thomas Steur's avatar Thomas Steur
Parcourir les fichiers

fixes #5951 throw an exception in getRowEvolution if a report is request that...

fixes #5951 throw an exception in getRowEvolution if a report is request that does not have a dimension
parent a2f3959a
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -8,6 +8,7 @@ This is a changelog for Piwik platform developers. All changes for our HTTP API' ...@@ -8,6 +8,7 @@ This is a changelog for Piwik platform developers. All changes for our HTTP API'
* The [settings](http://developer.piwik.org/guides/piwik-configuration) API will receive the actual entered value and will no longer convert characters like `&` to `&`. If you still want this behavior - for instance to prevent XSS - you can define a filter by setting the `transform` property like this: * The [settings](http://developer.piwik.org/guides/piwik-configuration) API will receive the actual entered value and will no longer convert characters like `&` to `&`. If you still want this behavior - for instance to prevent XSS - you can define a filter by setting the `transform` property like this:
`$setting->transform = function ($value) { return Common::sanitizeInputValue($value); }` `$setting->transform = function ($value) { return Common::sanitizeInputValue($value); }`
* Config setting `disable_merged_assets` moved from `Debug` section to `Development`. The updater will automatically change the section for you. * Config setting `disable_merged_assets` moved from `Debug` section to `Development`. The updater will automatically change the section for you.
* `API.getRowEvolution` will throw an exception if a report is requested that does not have a dimension, for instance `VisitsSummary.get`. This is a fix as an invalid format was returned before see [#5951](https://github.com/piwik/piwik/issues/5951)
### Deprecations ### Deprecations
The following events are considered as deprecated and the new structure should be used in the future. We have not scheduled when those events will be removed but probably in Piwik 3.0 which is not scheduled yet and won't be soon. New features will be added only to the new classes. The following events are considered as deprecated and the new structure should be used in the future. We have not scheduled when those events will be removed but probably in Piwik 3.0 which is not scheduled yet and won't be soon. New features will be added only to the new classes.
......
...@@ -331,6 +331,10 @@ class RowEvolution ...@@ -331,6 +331,10 @@ class RowEvolution
$metrics = $metrics + $reportMetadata['processedMetrics']; $metrics = $metrics + $reportMetadata['processedMetrics'];
} }
if (empty($reportMetadata['dimension'])) {
throw new Exception(sprintf('Reports like %s.%s which do not have a dimension are not supported by row evolution', $apiModule, $apiAction));
}
$dimension = $reportMetadata['dimension']; $dimension = $reportMetadata['dimension'];
return compact('metrics', 'dimension'); return compact('metrics', 'dimension');
......
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Plugins\API\tests;
use Piwik\Plugins\API\RowEvolution;
use Piwik\Tests\Fixture;
/**
* @group API
* @group RowEvolutionTest
* @group Database
*/
class RowEvolutionTest extends \DatabaseTestCase
{
public function setUp()
{
parent::setUp();
Fixture::createWebsite('2014-01-01 00:00:00');
}
/**
* @expectedException \Exception
* @expectedExceptionMessage Reports like VisitsSummary.get which do not have a dimension are not supported by row evolution
*/
public function test_getRowEvolution_shouldTriggerAnException_IfReportHasNoDimension()
{
$rowEvolution = new RowEvolution();
$rowEvolution->getRowEvolution(1, 'day', 'last7', 'VisitsSummary', 'get');
}
public function test_getRowEvolution_shouldNotTriggerAnException_IfReportHasADimension()
{
$rowEvolution = new RowEvolution();
$table = $rowEvolution->getRowEvolution(1, 'day', 'last7', 'Actions', 'getPageUrls');
$this->assertNotEmpty($table);
}
}
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter