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

Inconsistency in some property types of Actions.getPageTitles API #19963

Open
snake14 opened this issue Nov 7, 2022 · 2 comments
Open

Inconsistency in some property types of Actions.getPageTitles API #19963

snake14 opened this issue Nov 7, 2022 · 2 comments
Labels
c: Tests & QA For issues related to automated tests or making it easier to QA & test issues.

Comments

@snake14
Copy link
Contributor

snake14 commented Nov 7, 2022

I was updating the WhiteLabel premium plugin to build using PHP 8.1 instead of 8.0 and found that the entry_nb_uniq_visitors and exit_nb_uniq_visitors properties were previously string values and changed to Integer values when using PHP 8.1. I was able to fix the build by having two separate JSON files depending on which PHP version is running, but @mattab made the point that it's better to cast the values to keep them consistent.

Expected Behavior

When I make the following API call, it should return the same result whether I'm using PHP 8.1 or and earlier version:
https://{myMatomoDomain}/index.php?module=API&format=JSON&idSite=1&period=day&date=2022-10-07&method=Actions.getPageTitles&token_auth={myAuthToken}

Current Behavior

When I make the following API call, the entry_nb_uniq_visitors and exit_nb_uniq_visitors properties change typed depending on whether I'm using PHP 8.1 or and earlier version:
https://{myMatomoDomain}/index.php?module=API&format=JSON&idSite=1&period=day&date=2022-10-07&method=Actions.getPageTitles&token_auth={myAuthToken}

Possible Solution

As mentioned above, Matt suggested casting the properties to the expected type to keep the response consistent.

Steps to Reproduce (for Bugs)

  1. Be running PHP 8.1 and call the following API: https://{myMatomoDomain}/index.php?module=API&format=JSON&idSite=1&period=day&date=2022-10-07&method=Actions.getPageTitles&token_auth={myAuthToken}

Context

This broke the WhiteLabel build when I updated it from 8.0 to 8.1. We don't want to break things for clients when they upgrade PHP versions. This is just one API example, but there are probably others.

Your Environment

  • Matomo Version: 4.12.3
  • PHP Version: 8.1
@snake14 snake14 added the Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. label Nov 7, 2022
@heurteph-ei
Copy link

I think that for compatibility, it should stay as it worked before (string), but maybe in Matomo V5, it should be updated to number as these values are... Numbers!
Is there any impact in the HTTP API?

@sgiehl
Copy link
Member

sgiehl commented Nov 7, 2022

@heurteph-ei I can only agree partially. The API responses might be returned localized, so numbers might be formatted, which will require them to be a string in most cases.

@peterhashair peterhashair added c: Tests & QA For issues related to automated tests or making it easier to QA & test issues. and removed Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. labels Nov 9, 2022
@peterhashair peterhashair added this to the For Prioritization milestone Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Tests & QA For issues related to automated tests or making it easier to QA & test issues.
Projects
None yet
Development

No branches or pull requests

4 participants