@bx80 opened this Pull Request on July 26th 2022 Contributor

Description:

Steps to recreate:
1) Create a new custom report, add any dimension/metric
2) Run ./console core:archive
3) Check the output for period = year - only the previous year is processed, not the current year.

When archiving starts for a custom report, a check is done for any existing archives and if missing then invalidations are created for each period in the current year: days, weeks, months and year. These are created correctly with one invalidation for the current year (2022).

After processing each period the core/CronArchive::repairInvalidationsIfNeeded method is run to make sure any higher level invalidations exist (eg. if a week was just updated then make sure the higher level month and year are invalidated as those figures will have changed)

This doesn't cause any problems for day periods as every processed day will be in the current year, months also never span years.

However if there is a week which spans the previous and current year (eg. Monday 2021-12-27 to Sunday 2022-01-02) then repairInvalidationIfNeeded will look for a year invalidation for 2021 (the week's start date year) and when it fails to find one it will replace the previously created 2022 year invalidation with a 2021 year invalidation.

This results in no archive for the current year and an unnecessary archive for the previous year.

This PR adds a simple check to skip any attempt to repair a year validation if the week spans more than one year, a similar check already exists for weeks that span two months. (https://github.com/matomo-org/matomo/pull/16886#discussion_r537920138)

As repairInvalidationIfNeeded is part of the main archiving process this issue likely affects all archiving and is not specific to Custom Reports.

Ref L3-290
Also looks like it Fixes #18343

Review

@justinvelluppillai commented on July 26th 2022 Member

Nice find @bx80 and great description in the PR!

@sgiehl commented on July 27th 2022 Member

@bx80 any chance for adding a useful test for that? If that doesn't work for core, we could at least add one in custom reports plugin, to ensure this doesn't regress later.

This Pull Request was closed on August 8th 2022
Powered by GitHub Issue Mirror