Skip to content

Add exception for invalid limit before grouping #19881

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

Merged
merged 17 commits into from
Nov 6, 2022
Merged

Add exception for invalid limit before grouping #19881

merged 17 commits into from
Nov 6, 2022

Conversation

peterhashair
Copy link
Contributor

Description:

Fixes: #19867
Add an exception for invalid limit before grouping. When URL passing limitBeforeGrouping=all will throw an exception.

Review

add exception for invalid limit before grouping
@peterhashair peterhashair added this to the 4.12.2 milestone Oct 19, 2022
@peterhashair peterhashair added the Needs Review PRs that need a code review label Oct 20, 2022
@justinvelluppillai justinvelluppillai modified the milestones: 4.12.2, 4.12.3 Oct 21, 2022
Copy link
Contributor

@bx80 bx80 left a comment

Choose a reason for hiding this comment

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

Could this cause the limitBeforeGrouping parameter default value of false to throw an exception if the method was called directly outside the API? Maybe the default value should be 0?

Minor point: the test name has a typo test_InvalideLimitBeforeGroup

Peter and others added 2 commits October 26, 2022 11:22
update getTransitionsForAction limitBeforeGrouping default to int
@justinvelluppillai justinvelluppillai modified the milestones: 4.12.3, 4.12.4 Oct 27, 2022
remove translation
* @param string $parts
* @return array
* @throws Exception
*/
public function getTransitionsForAction($actionName, $actionType, $idSite, $period, $date,
$segment = false, $limitBeforeGrouping = false, $parts = 'all')
$segment = false, $limitBeforeGrouping = 0, $parts = 'all')
Copy link
Member

Choose a reason for hiding this comment

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

I guess it would make sense to also change that for all other API methods, otherwise the same error could occur there as well.
And it might also make sense to check and change all methods were that parameter is passed through, as some of them also use false as default...

Copy link
Contributor Author

@peterhashair peterhashair Nov 3, 2022

Choose a reason for hiding this comment

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

@sgiehl that makes sense, update a couple of places, and I notice when $limitBeforeGrouping is given as a string '1' or '20' is will state as an error as well, added intval will fix it without through errors, would that works.

@sgiehl sgiehl removed the Needs Review PRs that need a code review label Nov 2, 2022
Peter added 9 commits November 3, 2022 09:59
update all other place from false to 0
update ranking Query from false to 0
add more tests
update tests
remove throw errors
remove exception for other places
add throw and tests back
update intval to int and false condition
revert ranking query from false to 0
@peterhashair
Copy link
Contributor Author

There could be a chance of RankingQuery passing in a string, float, or negative number. But the chance is rarer.

@peterhashair peterhashair requested review from bx80 and sgiehl November 3, 2022 21:57
@peterhashair peterhashair added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Nov 4, 2022
Copy link
Contributor

@bx80 bx80 left a comment

Choose a reason for hiding this comment

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

Tests pass, I can't see any outstanding issues with the code.

@peterhashair peterhashair merged commit 7f5d8a1 into 4.x-dev Nov 6, 2022
@peterhashair peterhashair deleted the 19867 branch November 6, 2022 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Development

Successfully merging this pull request may close these issues.

Add exception for invalid limit before grouping in API request
4 participants