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

Add exception for invalid limit before grouping in API request #19867

Closed
tsteur opened this issue Oct 17, 2022 · 3 comments · Fixed by #19881
Closed

Add exception for invalid limit before grouping in API request #19867

tsteur opened this issue Oct 17, 2022 · 3 comments · Fixed by #19881
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@tsteur
Copy link
Member

tsteur commented Oct 17, 2022

Using Matomo 4.12

Link to reproduce: https://demo.matomo.cloud/?module=API&limitBeforeGrouping=all&method=Transitions.getTransitionsForPageUrl&pageUrl=https://divezone.net/&idSite=1&period=day&date=yesterday&format=JSON&token_auth=anonymous

Backtrace:

Error: {"message":"Unsupported operand types: string + int","file":"/core/RankingQuery.php","line":288,"request_id":"a73eb","backtrace":" on /core/RankingQuery.php(288)\n#0 /core/RankingQuery.php(229): Piwik\RankingQuery->generateRankingQuery('SELECT /* sites...')\n#1 /core/DataAccess/LogAggregator.php(981): Piwik\RankingQuery->execute('SELECT /* sites...', Array, 300)\n#2 /plugins/Transitions/API.php(459): Piwik\DataAccess\LogAggregator->queryActionsByDimension(Array, 'log_link_visit_...', Array, Array, Object(Piwik\RankingQuery), Array, 'name', 300)\n#3 /plugins/Transitions/API.php(195): Piwik\Plugins\Transitions\API->queryInternalReferrers('144', 'url', Object(Piwik\DataAccess\LogAggregator), 'all')\n#4 /plugins/Transitions/API.php(93): Piwik\Plugins\Transitions\API->addInternalReferrers(Object(Piwik\DataAccess\LogAggregator), Array, '144', 'url', 'all')\n#5 /plugins/Transitions/API.php(46): Piwik\Plugins\Transitions\API->getTransitionsForAction('https://divezon...', 'url', '1', Object(Piwik\Period\Day), 'yesterday', Object(Piwik\Segment), 'all')\n#6 [internal function]: Piwik\Plugins\Transitions\API->getTransitionsForPageUrl('https://divezon...', '1', 'day', 'yesterday', false, 'all')\n#7 /core/API/Proxy.php(244): call_user_func_array(Array, Array)\n#8 /core/Context.php(28): Piwik\API\Proxy->Piwik\API\{closure}()\n#9 /core/API/Proxy.php(335): Piwik\Context::executeWithQueryParameters(Array, Object(Closure))\n#10 /core/API/Request.php(267): Piwik\API\Proxy->call('\\Piwik\\Plugins\\...', 'getTransitionsF...', Array)\n#11 /plugins/API/Controller.php(45): Piwik\API\Request->process()\n#12 [internal function]: Piwik\Plugins\API\Controller->index()\n#13 /core/FrontController.php(631): call_user_func_array(Array, Array)\n#14 /core/FrontController.php(169): Piwik\FrontController->doDispatch('API', false, Array)\n#15 /core/dispatch.php(32): Piwik\FrontController->dispatch()\n#16 /index.php(25): require_once('/c...')\n#17 {main}","safemode_backtrace":"#0 [internal function]: Piwik\Plugins\Cloud\Controller->safemode(Array)\n#1 /core/FrontController.php(631): call_user_func_array(Array, Array)\n#2 /core/FrontController.php(169): Piwik\FrontController->doDispatch('Cloud', 'safemode', Array)\n#3 /core/FrontController.php(100): Piwik\FrontController->dispatch('CorePluginsAdmi...', 'safemode', Array)\n#4 /core/FrontController.php(140): Piwik\FrontController::(Array)\n#5 /core/FrontController.php(190): Piwik\FrontController::(Object(TypeError))\n#6 /core/dispatch.php(32): Piwik\FrontController->dispatch()\n#7 /index.php(25): require_once('/c...')\n#8 {main}"}

@tsteur tsteur added the Bug For errors / faults / flaws / inconsistencies etc. label Oct 17, 2022
@peterhashair
Copy link
Contributor

I can reproduce this on my local, seems like this line, $this->limit is 'all'

$limit = $this->limit + 1;

@peterhashair peterhashair added this to the 4.12.1 milestone Oct 17, 2022
@peterhashair
Copy link
Contributor

@tsteur just checking it seems like this is caused by the wrong param limitBeforeGrouping=all, do we want to throw an error on that one? Or do we want to accept the all

@tsteur
Copy link
Member Author

tsteur commented Oct 18, 2022

No big preference. Not sure what we're doing in other places if we were to use a wrong value?

I tried https://apache.matomo/index.php?module=API&format=JSON&idSite=1&period=year&date=2022-10-08&method=Live.getLastVisitsDetails&filter_limit=all&expanded=1&token_auth=...&force_api_session=1 and it didn't throw an error and just worked. Not sure how it is implemented there?

@justinvelluppillai justinvelluppillai modified the milestones: 4.12.1, 4.12.2, 4.12.3 Oct 19, 2022
@peterhashair peterhashair self-assigned this Oct 26, 2022
@justinvelluppillai justinvelluppillai modified the milestones: 4.12.3, 4.12.4 Oct 27, 2022
@elabuwa elabuwa changed the title Fatal error Unsupported operand types: string + int in RankingQuery.php Add exception for invalid limit before grouping Nov 22, 2022
@elabuwa elabuwa changed the title Add exception for invalid limit before grouping Add exception for invalid limit before grouping in API request Nov 22, 2022
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants