Unwanted date filter automatically added to Live.getLastVisitsDetails #17237
Labels
Regression
Indicates a feature used to work in a certain way but it no longer does even though it should.
Milestone
I've been working on migrating a system from Piwik 3 to Matomo 4; as part of this, I've been investigating why an API call which worked on the old system isn't working on the new one.
In brief, our system is making the following call:
/index.php?module=API&method=Live.getLastVisitsDetails&idSite=1&token_auth=xxxxxx&filter_limit=-1&segment=visitId%3D%3D12345678
I.e. we're requesting the details of a specific visit from a specific site.
However, on the new system, this was returning zero results.
Having dug into the code, I can see what's triggering this. In brief, it's because we've set the filter_limit to -1.
I.e, loadLastVisitsDetailsFromDatabase() is always hardcoding $checkforMoreEntries to true when it calls queryLogVisits(). And that means that queryLogVisits() increments $limit from -1 to 0, which then triggers the "last 24 hours" rule.
For now, and for this specific scenario, I can fix things by setting filter_limit to 1 (which will then be converted to 2 within queryLogVisits), since we're looking for a specific visit and therefore will only ever get one result back.
However, this feels like a logic issue; the documentation (https://developer.matomo.org/api-reference/reporting-api) still states that setting filter_limit to -1 is valid, and if the caller has requested an unlimited number of results, there shouldn't be any additional filters being applied!
It feels like the fix should be to check what value is set for filter_limit before setting $checkforMoreEntries.
The text was updated successfully, but these errors were encountered: