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 handling of invalid limit values for Live.getVisitorProfile #18711

Closed
tsteur opened this issue Jan 31, 2022 · 2 comments · Fixed by #18716
Closed

Fix handling of invalid limit values for Live.getVisitorProfile #18711

tsteur opened this issue Jan 31, 2022 · 2 comments · Fixed by #18716
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@tsteur
Copy link
Member

tsteur commented Jan 31, 2022

Can be reproduced on the demo: https://demo.matomo.cloud/?module=API&method=Live.getVisitorProfile&idSite=1&format=JSON&limitVisits=all and also locally getting an error there.

PHP 8.0.

see https://github.com/matomo-org/matomo/blob/4.7.0-rc2/plugins/Live/VisitorDetails.php#L218 we might need to double check that a row is actually there.

Error: {"message":"Call to a member function getColumn() on bool","file":"/plugins/Live/VisitorDetails.php","line":218,"request_id":"0950d","backtrace":" on /plugins/Live/VisitorDetails.php(218)\n#0 /plugins/Live/VisitorProfile.php(67): Piwik\Plugins\Live\VisitorDetails->finalizeProfile(Object(Piwik\DataTable), Array)\n#1 /plugins/Live/API.php(228): Piwik\Plugins\Live\VisitorProfile->makeVisitorProfile(Object(Piwik\DataTable), 'a687a3d0666fa4f...', false, 0)\n#2 [internal function]: Piwik\Plugins\Live\API->getVisitorProfile('1', 'a687a3d0666fa4f...', false, 0)\n#3 /core/API/Proxy.php(244): call_user_func_array(Array, Array)\n#4 /core/Context.php(28): Piwik\API\Proxy-

@tsteur tsteur added the Bug For errors / faults / flaws / inconsistencies etc. label Jan 31, 2022
@tsteur tsteur added this to the 4.8.0 milestone Jan 31, 2022
@sgiehl
Copy link
Member

sgiehl commented Feb 1, 2022

@tsteur the problem actually is that all is not supported for limitVisits. The code that behaves differently on PHP 7 vs PHP 8 is this part:

matomo/plugins/Live/API.php

Lines 207 to 211 in 0e910f0

if ($limitVisits <= 0) {
$limitVisits = VisitorProfile::VISITOR_PROFILE_MAX_VISITS_TO_SHOW;
} else {
$limitVisits = (int) $limitVisits;
}

'all' <= 0 is true on PHP 7, while it is false on PHP 8

I'll prepare a PR to fix the handling of invalid values.

@tsteur
Copy link
Member Author

tsteur commented Feb 1, 2022

👍

@justinvelluppillai justinvelluppillai changed the title Fatal error Call to a member function getColumn() on bool" in /Live/VisitorDetails.php on line 218 Fix handling of invalid limit values for Live.getVisitorProfile Feb 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.

2 participants