diff options
author | Ben Burgess <88810029+bx80@users.noreply.github.com> | 2022-03-08 23:21:06 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-08 23:21:06 +0300 |
commit | 680db1156be27769709bf9a6e7f67636e7cfb8dc (patch) | |
tree | 63f614e3dc1e81d015415bd047dae4d9b0f9187c /core | |
parent | 05397a2a7a3c0cb5ae73e64ca2f5f8cc0ff7cbdc (diff) |
Prevent archiving of data for time periods that start in the future (#18790)
* Prevent archiving data later than today instead of today + 2days
* Added archive test to check that periods that start in the future are not archived
* Allow for local time being a day ahead of UTC when skipping archive ranges
* Added test for website with local time in the previous day from the current UTC time
Diffstat (limited to 'core')
-rw-r--r-- | core/Archive.php | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/core/Archive.php b/core/Archive.php index 26abc2ce0a..09227df4d8 100644 --- a/core/Archive.php +++ b/core/Archive.php @@ -610,10 +610,7 @@ class Archive implements ArchiveQuery */ private function cacheArchiveIdsAfterLaunching($archiveGroups, $plugins) { - $today = Date::today(); - foreach ($this->params->getPeriods() as $period) { - $twoDaysBeforePeriod = $period->getDateStart()->subDay(2); $twoDaysAfterPeriod = $period->getDateEnd()->addDay(2); foreach ($this->params->getIdSites() as $idSite) { @@ -635,8 +632,11 @@ class Archive implements ArchiveQuery continue; } - // if the starting date is in the future we know there is no visiidsite = ?t - if ($twoDaysBeforePeriod->isLater($today)) { + // Allow for site timezone, local time may have started a new day ahead of UTC + $today = \Piwik\Date::factory('now', $site->getTimezone()); + + // if the starting date is in the future we know there are no visits + if ($period->getDateStart()->isLater($today)) { Log::debug("Archive site %s, %s (%s) skipped, archive is after today.", $idSite, $period->getLabel(), $period->getPrettyString()); continue; |