-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Limit date ranges that end far in the future #22592
base: 5.x-dev
Are you sure you want to change the base?
Conversation
007a431
to
a72d66c
Compare
a72d66c
to
707cc29
Compare
* | ||
* @return int | ||
*/ | ||
public static function getMaxAllowedEndTimestamp(): int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the method need to be public if not used elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't and it might not even need to be static. But this new "Limit" is supposed to be something global for ranges. So it imho should be reusable if needed anywhere else.
We could actually even consider to mark this method as @api
, so it will be shown in the documentation 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, ok, well if we want to have it in the API scope, then yeah, keep it public. With the static vs dynamic, it seemed to me we prefer dynamic in a lot of places, even just to get a single thing we instantiate a class.. so I could see that used here as well.
Description:
Matomo currently only restricts provided dates in the past. A date currently can't be set to earlier than August 1991 - the date were the first website went live.
Future dates are currently not restricted, even though it doesn't make sense to provide dates that are far in the future. As Matomo won't archive future dates, there can't be any data returned anyway.
Providing single periods like
day
,week
,month
oryear
far in the future is unproblematic, as Matomo would simply display no data for it.Range periods and multiple period requests however are a bit different, as Matomo would try to process all subperiods that are included. As dates in the future can't have any data anyway, there is not much value in even trying to process those dates unlimited.
Therefor this PR introduces an internal limit for range periods. If a range is provided with an end date that is more than 10 years in the future, Matomo will automatically cut down the range to end at end of the current year + 10 years.
Review