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

Allow rearchive_reports_in_past_last_n_months setting value to be an int. #17368

Merged
merged 3 commits into from Mar 23, 2021

Conversation

diosmosis
Copy link
Member

Description:

Fixes #17366

Review

  • Functional review done
  • Potential edge cases thought about (behavior of the code with strange input, with strange internal state or possible interactions with other Matomo subsystems)
  • 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

@diosmosis diosmosis added the Needs Review PRs that need a code review label Mar 22, 2021
@diosmosis diosmosis added this to the 4.3.0 milestone Mar 22, 2021
@diosmosis diosmosis added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Mar 22, 2021
@flamisz
Copy link
Contributor

flamisz commented Mar 22, 2021

Do we want to change the default settings in the global.ini.php. Currently, it is last6.

What about the other files where we use this setting? We still check for substr in plugins/CustomReports/Controller.php or plugins/CustomReports/Widgets/GetManageReports.php.

if (isset($general['rearchive_reports_in_past_last_n_months'])) {
    $reArchiveLastN = (int) substr($general['rearchive_reports_in_past_last_n_months'], 4);
}

@diosmosis
Copy link
Member Author

Do we want to change the default settings in the global.ini.php. Currently, it is last6.

this is up to @tsteur

We still check for substr in plugins/CustomReports/Controller.php or plugins/CustomReports/Widgets/GetManageReports.php.

A PR exists for those now.

@tsteur
Copy link
Member

tsteur commented Mar 22, 2021

Either last6 or 6 is fine regarding the default setting. No preference.

Copy link
Contributor

@flamisz flamisz left a comment

Choose a reason for hiding this comment

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

LGTM

@diosmosis
Copy link
Member Author

thanks for the quick review @flamisz 👍

if (empty($lastNMonthsToInvalidate)) {
return null;
if (!is_numeric($lastNMonthsToInvalidate)) {
$lastNMonthsToInvalidate = (int)str_replace('last', '', $lastNMonthsToInvalidate);
Copy link
Member

Choose a reason for hiding this comment

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

In theory this would also allow values like last2last1 and would result in 21. Not sure if we wouldn't want to discard such incorrect values instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

cc @tsteur

Copy link
Member

Choose a reason for hiding this comment

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

I think it's not needed and could keep things simple. People will mostly just configure a number anyway.

@diosmosis diosmosis merged commit 8663164 into 4.x-dev Mar 23, 2021
@diosmosis diosmosis deleted the 17366-rearchive-setting-simplify branch March 23, 2021 04:16
@nelhefni
Copy link

nelhefni commented Mar 23, 2021

@diosmosis thanks for the fix! This should help to fix this issue: https://forum.matomo.org/t/new-funnel-triggers-past-report-generation/41152/4
Before your fix, rearchive_reports_in_past_last_n_months = 0 would throw an exception, because empty(0) is true, meaninggetEarliestDateToRearchive() was returning null instead of the current month, leading to an issue in the calling method.

That being said, there is still a problem. If I set rearchive_reports_in_past_last_n_months = 0 I would expect no past report to be generated when I update a Funnel, but because of setDay(1) we will always re-generate report since the first day of the current month.
https://github.com/matomo-org/matomo/blob/4.x-dev/core/Archive/ArchiveInvalidator.php#L806

@diosmosis
Copy link
Member Author

good catch @nelhefni, i'll fix this today

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.

Improve configuration of rearchive_reports_in_past_last_n_months setting
5 participants