Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md3
-rw-r--r--core/API/ResponseBuilder.php37
-rw-r--r--plugins/API/Controller.php7
-rwxr-xr-xplugins/Annotations/javascripts/annotations.js6
-rw-r--r--plugins/CoreAdminHome/angularjs/trackingcode/imagetrackingcode.controller.js1
-rw-r--r--plugins/CoreAdminHome/angularjs/trackingcode/jstrackingcode.controller.js3
-rw-r--r--plugins/CoreHome/angularjs/common/services/report-metadata-model.js1
-rw-r--r--plugins/CoreHome/angularjs/common/services/reporting-pages-model.js2
-rw-r--r--plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.model.js2
-rw-r--r--plugins/Dashboard/angularjs/common/services/dashboards-model.js2
-rw-r--r--plugins/Dashboard/javascripts/dashboard.js3
-rw-r--r--plugins/Dashboard/javascripts/dashboardObject.js3
-rw-r--r--plugins/Dashboard/javascripts/widgetMenu.js1
-rw-r--r--plugins/SitesManager/angularjs/sites-manager/sites-manager-type-model.js2
-rw-r--r--plugins/Transitions/javascripts/transitions.js1
-rw-r--r--plugins/UsersManager/angularjs/give-user-view-access/give-user-view-access.controller.js7
-rw-r--r--tests/PHPUnit/Unit/API/ResponseBuilderTest.php14
17 files changed, 41 insertions, 54 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fc6bbf7b25..c2d8f919a5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,7 +18,8 @@ This is a changelog for Piwik platform developers. All changes for our HTTP API'
* The method `Piwik\Plugin\Controller::getEvolutionHtml` has been removed without a replacement as it should be no longer needed. The evolution is generated by ViewDataTables directly
* The `core:plugin` console command has been removed in favor of the new `plugin:list`, `plugin:activate` and `plugin:deactivate` commands as anounced in Piwik 2.11
* The visibility of private properties and methods in `Piwik\Plugins\Login\Controller` were changed to `protected`
-* Controller actions are now case sensitive. This means the URL and events have to use the same case as the name of the action defined in a controller.
+* Controller actions are now case sensitive. This means the URL and events have to use the same case as the name of the action defined in a controller.
+* When calling the HTTP Reporting API, a default filter limit of 100 is now always applied. The default filter limit used to be not applied to API calls that do not return reports, such as when requesting sites, users or goals information.
* The "User Menu" was removed and should be replaced by "Admin Menu". Change `configureUserMenu(MenuUser $menu)` to `configureAdminMenu(MenuAdmin $menu)` in your `Menu.php`.
* The method `Piwik\Menu\MenuAdmin::addSettingsItem()` was removed, use `Piwik\Menu\MenuAdmin::addSystemItem()` instead.
* A new methd `Piwik\Menu\MenuAdmin::addMeasurablesItem()` was added.
diff --git a/core/API/ResponseBuilder.php b/core/API/ResponseBuilder.php
index 3fe13f9631..d28c92a999 100644
--- a/core/API/ResponseBuilder.php
+++ b/core/API/ResponseBuilder.php
@@ -200,7 +200,10 @@ class ResponseBuilder
$limit = Common::getRequestVar('filter_limit', -1, 'integer', $this->request);
$offset = Common::getRequestVar('filter_offset', '0', 'integer', $this->request);
- if ($this->shouldApplyLimitOnArray($limit, $offset)) {
+ if ($limit >= 0 || $offset > 0) {
+ if ($limit < 0) {
+ $limit = null; // make sure to return all results from offset
+ }
$array = array_slice($array, $offset, $limit, $preserveKeys = false);
}
}
@@ -217,38 +220,6 @@ class ResponseBuilder
return $this->apiRenderer->renderArray($array);
}
- private function shouldApplyLimitOnArray($limit, $offset)
- {
- if ($limit === -1) {
- // all fields are requested
- return false;
- }
-
- if ($offset > 0) {
- // an offset is specified, we have to apply the limit
- return true;
- }
-
- // "api_datatable_default_limit" is set by API\Controller if no filter_limit is specified by the user.
- // it holds the number of the configured default limit.
- $limitSetBySystem = Common::getRequestVar('api_datatable_default_limit', -2, 'integer', $this->request);
-
- // we ignore the limit if the datatable_default_limit was set by the system as this default filter_limit is
- // only meant for dataTables but not for arrays. This way we stay BC as filter_limit was not applied pre
- // Piwik 2.6 and some fixes were made in Piwik 2.13.
- $wasFilterLimitSetBySystem = $limitSetBySystem !== -2;
-
- // we check for "$limitSetBySystem === $limit" as an API method could request another API method with
- // another limit. In this case we need to apply it again.
- $isLimitStillDefaultLimit = $limitSetBySystem === $limit;
-
- if ($wasFilterLimitSetBySystem && $isLimitStillDefaultLimit) {
- return false;
- }
-
- return true;
- }
-
private function sendHeaderIfEnabled()
{
if ($this->sendHeader) {
diff --git a/plugins/API/Controller.php b/plugins/API/Controller.php
index 5a15c6dbe7..e7ef5efd36 100644
--- a/plugins/API/Controller.php
+++ b/plugins/API/Controller.php
@@ -29,8 +29,11 @@ class Controller extends \Piwik\Plugin\Controller
// when calling the API through http, we limit the number of returned results
if (!isset($_GET['filter_limit'])) {
- $_GET['filter_limit'] = Config::getInstance()->General['API_datatable_default_limit'];
- $token .= '&api_datatable_default_limit=' . $_GET['filter_limit'];
+ if (isset($_POST['filter_limit'])) {
+ $_GET['filter_limit'] = $_POST['filter_limit'];
+ } else {
+ $_GET['filter_limit'] = Config::getInstance()->General['API_datatable_default_limit'];
+ }
}
$request = new Request($token);
diff --git a/plugins/Annotations/javascripts/annotations.js b/plugins/Annotations/javascripts/annotations.js
index f699b3aec9..b6d08e9856 100755
--- a/plugins/Annotations/javascripts/annotations.js
+++ b/plugins/Annotations/javascripts/annotations.js
@@ -17,7 +17,8 @@
action: 'getAnnotationManager',
idSite: idSite,
date: date,
- period: period
+ period: period,
+ filter_limit: '-1'
};
if (lastN) {
ajaxParams.lastN = lastN;
@@ -102,7 +103,8 @@
action: 'getEvolutionIcons',
idSite: idSite,
date: date,
- period: period
+ period: period,
+ filter_limit: '-1'
};
if (lastN) {
ajaxParams.lastN = lastN;
diff --git a/plugins/CoreAdminHome/angularjs/trackingcode/imagetrackingcode.controller.js b/plugins/CoreAdminHome/angularjs/trackingcode/imagetrackingcode.controller.js
index 18c97bab38..c19885ac7a 100644
--- a/plugins/CoreAdminHome/angularjs/trackingcode/imagetrackingcode.controller.js
+++ b/plugins/CoreAdminHome/angularjs/trackingcode/imagetrackingcode.controller.js
@@ -47,6 +47,7 @@
goalPromises[idSite] = piwikApi.fetch({
module: 'API',
method: 'Goals.getGoals',
+ filter_limit: '-1',
idSite: idSite
});
}
diff --git a/plugins/CoreAdminHome/angularjs/trackingcode/jstrackingcode.controller.js b/plugins/CoreAdminHome/angularjs/trackingcode/jstrackingcode.controller.js
index 4f222016c8..a7c8dbaeae 100644
--- a/plugins/CoreAdminHome/angularjs/trackingcode/jstrackingcode.controller.js
+++ b/plugins/CoreAdminHome/angularjs/trackingcode/jstrackingcode.controller.js
@@ -58,7 +58,8 @@
piwikApi.fetch({
module: 'API',
method: 'SitesManager.getSiteUrlsFromId',
- idSite: idSite
+ idSite: idSite,
+ filter_limit: '-1'
}).then(function (data) {
self.siteUrls[idSite] = data || [];
diff --git a/plugins/CoreHome/angularjs/common/services/report-metadata-model.js b/plugins/CoreHome/angularjs/common/services/report-metadata-model.js
index f158861423..fcf8e4690e 100644
--- a/plugins/CoreHome/angularjs/common/services/report-metadata-model.js
+++ b/plugins/CoreHome/angularjs/common/services/report-metadata-model.js
@@ -40,6 +40,7 @@
reportsPromise = piwikApi.fetch({
method: 'API.getReportMetadata',
idSites: piwik.idSite || piwik.broadcast.getValueFromUrl('idSite'),
+ filter_limit: '-1'
}).then(function (response) {
model.reports = response;
return response;
diff --git a/plugins/CoreHome/angularjs/common/services/reporting-pages-model.js b/plugins/CoreHome/angularjs/common/services/reporting-pages-model.js
index 1b1e406c95..1f0bbd91d7 100644
--- a/plugins/CoreHome/angularjs/common/services/reporting-pages-model.js
+++ b/plugins/CoreHome/angularjs/common/services/reporting-pages-model.js
@@ -46,7 +46,7 @@
function getAllPages()
{
if (!fetchAllPagesPromise) {
- fetchAllPagesPromise = piwikApi.fetch({method: 'API.getReportPagesMetadata'}).then(function (response) {
+ fetchAllPagesPromise = piwikApi.fetch({method: 'API.getReportPagesMetadata', filter_limit: '-1'}).then(function (response) {
model.pages = response;
return response;
});
diff --git a/plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.model.js b/plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.model.js
index ceb6442a8f..21a3b44d46 100644
--- a/plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.model.js
+++ b/plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.model.js
@@ -35,7 +35,7 @@
model.isLoading = true;
fetchCustomVariables().then(function () {
- return piwikApi.fetch({method: 'CustomVariables.getUsagesOfSlots'});
+ return piwikApi.fetch({method: 'CustomVariables.getUsagesOfSlots', filter_limit: '-1'});
}).then(function (customVariables) {
model.customVariables = customVariables;
diff --git a/plugins/Dashboard/angularjs/common/services/dashboards-model.js b/plugins/Dashboard/angularjs/common/services/dashboards-model.js
index 8cdfbec772..df2e147fa1 100644
--- a/plugins/Dashboard/angularjs/common/services/dashboards-model.js
+++ b/plugins/Dashboard/angularjs/common/services/dashboards-model.js
@@ -55,7 +55,7 @@
function getAllDashboards()
{
if (!dashboardsPromise) {
- dashboardsPromise = piwikApi.fetch({method: 'Dashboard.getDashboards'}).then(function (response) {
+ dashboardsPromise = piwikApi.fetch({method: 'Dashboard.getDashboards', filter_limit: '-1'}).then(function (response) {
if (response) {
model.dashboards = response;
}
diff --git a/plugins/Dashboard/javascripts/dashboard.js b/plugins/Dashboard/javascripts/dashboard.js
index 48c3430824..27ef28dfa0 100644
--- a/plugins/Dashboard/javascripts/dashboard.js
+++ b/plugins/Dashboard/javascripts/dashboard.js
@@ -99,7 +99,8 @@ function copyDashboardToUser() {
ajaxRequest.addParams({
module: 'API',
method: 'UsersManager.getUsers',
- format: 'json'
+ format: 'json',
+ filter_limit: '-1'
}, 'get');
ajaxRequest.setCallback(
function (availableUsers) {
diff --git a/plugins/Dashboard/javascripts/dashboardObject.js b/plugins/Dashboard/javascripts/dashboardObject.js
index 13862ecd5b..4165bfcaec 100644
--- a/plugins/Dashboard/javascripts/dashboardObject.js
+++ b/plugins/Dashboard/javascripts/dashboardObject.js
@@ -585,7 +585,8 @@
var ajaxRequest = new ajaxHelper();
ajaxRequest.addParams({
module: 'Dashboard',
- action: 'getAllDashboards'
+ action: 'getAllDashboards',
+ filter_limit: '-1'
}, 'get');
ajaxRequest.withTokenInUrl();
ajaxRequest.setCallback(success);
diff --git a/plugins/Dashboard/javascripts/widgetMenu.js b/plugins/Dashboard/javascripts/widgetMenu.js
index 100674ce00..d3d96569eb 100644
--- a/plugins/Dashboard/javascripts/widgetMenu.js
+++ b/plugins/Dashboard/javascripts/widgetMenu.js
@@ -69,6 +69,7 @@ widgetsHelper.getAvailableWidgets = function (callback) {
ajaxRequest.addParams({
module: 'API',
method: 'API.getWidgetMetadata',
+ filter_limit: '-1',
format: 'JSON',
deep: '1',
idSite: piwik.idSite || broadcast.getValueFromUrl('idSite')
diff --git a/plugins/SitesManager/angularjs/sites-manager/sites-manager-type-model.js b/plugins/SitesManager/angularjs/sites-manager/sites-manager-type-model.js
index c9901379b9..3ccb403e1f 100644
--- a/plugins/SitesManager/angularjs/sites-manager/sites-manager-type-model.js
+++ b/plugins/SitesManager/angularjs/sites-manager/sites-manager-type-model.js
@@ -36,7 +36,7 @@
function fetchAvailableTypes()
{
if (!typesPromise) {
- typesPromise = piwikApi.fetch({method: 'API.getAvailableMeasurableTypes'}).then(function (types) {
+ typesPromise = piwikApi.fetch({method: 'API.getAvailableMeasurableTypes', filter_limit: '-1'}).then(function (types) {
angular.forEach(types, function (type) {
model.typesById[type.id] = type;
diff --git a/plugins/Transitions/javascripts/transitions.js b/plugins/Transitions/javascripts/transitions.js
index 0da9580cf0..789cee2915 100644
--- a/plugins/Transitions/javascripts/transitions.js
+++ b/plugins/Transitions/javascripts/transitions.js
@@ -1477,6 +1477,7 @@ Piwik_Transitions_Ajax.prototype.callApi = function (method, params, callback) {
params.format = 'JSON';
params.module = 'API';
params.method = method;
+ params.filter_limit = '-1';
var ajaxRequest = new ajaxHelper();
ajaxRequest.addParams(params, 'get');
diff --git a/plugins/UsersManager/angularjs/give-user-view-access/give-user-view-access.controller.js b/plugins/UsersManager/angularjs/give-user-view-access/give-user-view-access.controller.js
index d44f145ad9..dd465557fa 100644
--- a/plugins/UsersManager/angularjs/give-user-view-access/give-user-view-access.controller.js
+++ b/plugins/UsersManager/angularjs/give-user-view-access/give-user-view-access.controller.js
@@ -79,7 +79,8 @@
piwikApi.fetch({
method: 'UsersManager.getUsersAccessFromSite',
userLogin: userLogin,
- idSite: idSites
+ idSite: idSites,
+ filter_limit: '-1'
}, requestOptions).then(function (users) {
var userLogins = [];
if (users) {
@@ -103,7 +104,7 @@
{
return piwikApi.fetch({
method: 'UsersManager.userExists',
- userLogin: usernameOrEmail,
+ userLogin: usernameOrEmail
}, requestOptions).then(function (response) {
return response;
@@ -117,7 +118,7 @@
{
return piwikApi.fetch({
method: 'UsersManager.getUserLoginFromUserEmail',
- userEmail: usernameOrEmail,
+ userEmail: usernameOrEmail
}, requestOptions).then(function (response) {
return response;
}, function () {
diff --git a/tests/PHPUnit/Unit/API/ResponseBuilderTest.php b/tests/PHPUnit/Unit/API/ResponseBuilderTest.php
index 14409c1913..6746b48c1e 100644
--- a/tests/PHPUnit/Unit/API/ResponseBuilderTest.php
+++ b/tests/PHPUnit/Unit/API/ResponseBuilderTest.php
@@ -234,7 +234,7 @@ class ResponseBuilderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($expectedResponse, $response);
}
- public function test_getResponse_shouldNotApplyLimit_IfLimitIsDefaultFilterLimitValueAndSetBySystem()
+ public function test_getResponse_shouldAlwaysApplyDefaultFilterLimit_EvenWhenResponseIsAnArray()
{
$input = range(0, 200);
$limit = Config::getInstance()->General['API_datatable_default_limit'];
@@ -246,7 +246,7 @@ class ResponseBuilderTest extends \PHPUnit_Framework_TestCase
'filter_offset' => 0));
$response = $builder->getResponse($input);
- $this->assertEquals(range(0, 200), $response);
+ $this->assertEquals(range(0, 99), $response);
}
public function test_getResponse_shouldApplyLimit_IfLimitIsSetBySystemButDifferentToDefaultLimit()
@@ -272,10 +272,11 @@ class ResponseBuilderTest extends \PHPUnit_Framework_TestCase
$this->assertLimitedResponseEquals($expected, $input, $limit = 15, $offset = 30);
}
- public function test_getResponse_shouldNotApplyFilterOffsetOnIndexedArray_IfNoFilterLimitIsSetButOffset()
+ public function test_getResponse_shouldApplyFilterOffsetOnIndexedArray_IfNoFilterLimitIsSetButOffset()
{
$input = range(0, 100);
- $this->assertLimitedResponseEquals($input, $input, $limit = null, $offset = 30);
+ $expected = range(30, 100);
+ $this->assertLimitedResponseEquals($expected, $input, $limit = null, $offset = 30);
}
public function test_getResponse_shouldReturnEmptyArrayOnIndexedArray_IfFilterLimitIsZero()
@@ -284,10 +285,11 @@ class ResponseBuilderTest extends \PHPUnit_Framework_TestCase
$this->assertLimitedResponseEquals($expected = array(), $input, $limit = 0, $offset = 30);
}
- public function test_getResponse_shouldIgnoreFilterOffsetOnIndexedArray_IfFilterLimitIsMinusOne()
+ public function test_getResponse_shouldApplyFilterOffsetOnIndexedArray_IfFilterLimitIsMinusOne()
{
$input = range(0, 100);
- $this->assertLimitedResponseEquals($input, $input, $limit = -1, $offset = 30);
+ $expected = range(30, 100);
+ $this->assertLimitedResponseEquals($expected, $input, $limit = -1, $offset = 30);
}
public function test_getResponse_shouldReturnAllOnIndexedArray_IfFilterLimitIsMinusOne()