New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect sort order when scheduled report uses custom report #13487

Merged
merged 2 commits into from Oct 1, 2018

Conversation

Projects
None yet
2 participants
@diosmosis
Member

diosmosis commented Sep 27, 2018

Make sure request parameters are loaded in superglobals when DataTablePostProcessor gets the Report instance.

DataTablePostProcessor will call ReportsProvider::factory(), but it will call it outside of Piwik\Api\Proxy, which means the request parameters won't be in $_GET/$_POST. So if the Report instance tries to access these in order to configure itself, it may not be able to find them.

Make sure request parameters are loaded in superglobals when DataTabl…
…ePostProcessor gets the Report instance.

@diosmosis diosmosis added this to the 3.6.1 milestone Sep 27, 2018

$saveQUERY_STRING = @$_SERVER['QUERY_STRING'];
foreach ($parametersRequest as $param => $value) {
$_GET[$param] = $value;
}

This comment has been minimized.

@tsteur

tsteur Sep 27, 2018

Member

wouldn't it also need to set $_POST or unset it temporarily etc?

This comment has been minimized.

@diosmosis

diosmosis Sep 27, 2018

Member

Possibly, this code was moved from API\Proxy.php, I didn't change it. We can make it override $_POST too, just didn't want to accidentally break something.

This comment has been minimized.

@tsteur

tsteur Oct 1, 2018

Member

sorry... only just noticing... I wonder if it breaks functionality if we also did $_GET = array();$_POST=array() before the foreach? but I think it actually could break functionality. not needed for now I guess as it probably has always been that way.

This comment has been minimized.

@tsteur

tsteur Oct 1, 2018

Member

actually pretty sure it would break behaviour... this is why we currently use $default = [] and needs to be changed there I suppose.

@@ -261,7 +262,12 @@ public function process()
// call the method
$returnedValue = Proxy::getInstance()->call($apiClassName, $method, $this->request);
$toReturn = $response->getResponse($returnedValue, $module, $method);
// get the response with the request query parameters loaded, since DataTablePost processor will use the Report

This comment has been minimized.

@tsteur

tsteur Sep 27, 2018

Member

@diosmosis does it make sense to move $returnedValue = Proxy::getInstance()->call($apiClassName, $method, $this->request); into this Context::executeWithQueryParameters below and remove it from the call method? The call method isn't API so we can change it.

This comment has been minimized.

@diosmosis

diosmosis Sep 27, 2018

Member

Some code does call Proxy::getInstance()->call() directly, eg, DataTableManipulators so I think it could break things.

@diosmosis

This comment has been minimized.

Member

diosmosis commented Sep 30, 2018

@tsteur Updated to save $_POST parameters as well.

@tsteur

tsteur approved these changes Oct 1, 2018

some ui tests are failing in https://builds-artifacts.matomo.org/matomo-org/matomo/3.x-dev/30298/ but doesn't look to be related to this change 👍

@diosmosis diosmosis merged commit 5c4c150 into 3.x-dev Oct 1, 2018

0 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details
continuous-integration/travis-ci/push The Travis CI build could not complete due to an error
Details

@diosmosis diosmosis deleted the custom-report-scheduled-report-sort branch Oct 1, 2018

InfinityVoid added a commit to InfinityVoid/matomo that referenced this pull request Oct 11, 2018

Fix incorrect sort order when scheduled report uses custom report (ma…
…tomo-org#13487)

* Make sure request parameters are loaded in superglobals when DataTablePostProcessor gets the Report instance.

* Save POST parameters in Context::executeWithQueryParameters().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment