Navigation Menu

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

Prevent possible error when action is provided as array #18706

Merged
merged 3 commits into from Feb 1, 2022
Merged

Conversation

sgiehl
Copy link
Member

@sgiehl sgiehl commented Jan 31, 2022

Description:

fixes #18701

Review

@sgiehl sgiehl added not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Needs Review PRs that need a code review labels Jan 31, 2022
@sgiehl sgiehl added this to the 4.8.0 milestone Jan 31, 2022
@@ -460,6 +460,10 @@ protected function prepareDispatch($module, $action, $parameters)

if (is_null($action)) {
$action = Common::getRequestVar('action', false);
if ($action !== false) {
// If a value was provided, check it has the correct type.
$action = Common::getRequestVar('action', null, 'string');
Copy link
Member Author

Choose a reason for hiding this comment

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

This will throw an exception with the message The parameter 'action' doesn't have a correct type, and a default value wasn't provided.

Directly using Piwik::getAction() would in theory also work, but it would change the behavior slightly. Instead of throwing an error when an incorrect type was provided, it would use an empty string as default instead.

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.

@sgiehl sgiehl merged commit 4fea439 into 4.x-dev Feb 1, 2022
@sgiehl sgiehl deleted the m-18701 branch February 1, 2022 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fatal error "ucfirst(): Argument #1 ($string) must be of type string" in ReportsProvider
2 participants