Skip to content
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

diosmosis
Copy link
Member

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.

@diosmosis diosmosis added Bug For errors / faults / flaws / inconsistencies etc. Needs Review PRs that need a code review labels Sep 27, 2018
@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;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@diosmosis
Copy link
Member Author

@tsteur Updated to save $_POST parameters as well.

Copy link
Member

@tsteur tsteur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@diosmosis diosmosis deleted the custom-report-scheduled-report-sort branch October 1, 2018 21:10
InfinityVoid pushed a commit to InfinityVoid/matomo that referenced this pull request Oct 11, 2018
…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
Labels
Bug For errors / faults / flaws / inconsistencies etc. Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants