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

Ensure metadata is available if page url can't be found #16920

Merged
merged 4 commits into from Jan 19, 2021

Conversation

sgiehl
Copy link
Member

@sgiehl sgiehl commented Dec 9, 2020

Description:

When sending a request like this:

{"module":"API","format":"rss","pageUrl":"\xxxxxxxxxxxx","idSite":"1","period":"day","date":"last7","token_auth":"XYZANONYMIZED","method":"Actions.getPageUrl","filter_limit":100}

the api method Actions.getPageUrl currently might return a completely empty datatable, if the url can't be found. But the RSS renderer tries to use the period metadata of the datatable, which does not exist, and fails.

Simply returning the first subtables metadata for the empty table response solves that issue.

fixes #16918

Review

  • Functional review done
  • Usability review done (is anything maybe unclear or think about anything that would cause people to reach out to support)
  • Security review done see checklist
  • Code review done
  • Tests were added if useful/possible
  • Reviewed for breaking changes
  • Developer changelog updated if needed
  • Documentation added if needed
  • Existing documentation updated if needed

@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 Dec 9, 2020
$subTable = reset($subTables);
$result->setAllTableMetadata($subTable->getAllTableMetadata());
}
return $result;
Copy link
Member

Choose a reason for hiding this comment

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

Will this actually set the correct period though? If we query with a multi period, then this will set it to the first subperiod, so in the last7 example, it would be 7 days ago. Is this what callers of the API would expect? I think maybe the Rss formatter doesn't support multiperiod requests, and some other changes are needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually no. That piece of code is executed for datatable maps inside a map. I'll remove some useless code so it gets more clear.

@diosmosis
Copy link
Member

It's a bit clearer, but I'm still unsure as to whether the period we pick in the list of tables will be what is expected by callers. I also noticed that this code doesn't appear to be tested (there don't seem to be any tests that call getPageUrl/getOutlink/etc.). Do you think it would be a good idea to add an integration or system test to cover this behavior and maybe check the period that is returned? If it's there isn't one already, perhaps there could be a rss test for this as well?

@sgiehl
Copy link
Member Author

sgiehl commented Jan 14, 2021

@diosmosis I've just added some RSS tests

@diosmosis
Copy link
Member

@sgiehl is there a test that requests a page URL that cannot be found (to trigger the bug this PR fixes)?

@sgiehl
Copy link
Member Author

sgiehl commented Jan 18, 2021

@diosmosis I've just added a test that should throw an exception on 4.x-dev

@diosmosis diosmosis merged commit 4e55cd0 into 4.x-dev Jan 19, 2021
@diosmosis diosmosis deleted the fixpagefilter branch January 19, 2021 03:42
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.

Call to a member function getDateStart() on boolean DataTable/Renderer/Rss.php
2 participants