diff options
author | diosmosis <diosmosis@users.noreply.github.com> | 2020-04-21 05:33:18 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-21 05:33:18 +0300 |
commit | 9aee02dfc45f961e8cce5ad062724dc3a7e9ccc1 (patch) | |
tree | c28842ce02f56c232554246ecddcd9c2b4b62020 | |
parent | 9b359e1525ccf65013376cf75b5eb406d29b5f4b (diff) |
Always purge today & yesterday and add update for 3.13.5 (#15832)3.13.5-rc1
* Always purge today/yesterday when running invalidated archive purge task and add update to add all tables to purge for next version.
* Add some comments.
* Only add dates if they are past 2020-03.
* Only add tables above 2020-01.
-rw-r--r-- | core/Updates/3.13.5-rc1.php | 45 | ||||
-rw-r--r-- | core/Version.php | 2 | ||||
-rw-r--r-- | plugins/CoreAdminHome/Tasks.php | 19 |
3 files changed, 65 insertions, 1 deletions
diff --git a/core/Updates/3.13.5-rc1.php b/core/Updates/3.13.5-rc1.php new file mode 100644 index 0000000000..d465c31683 --- /dev/null +++ b/core/Updates/3.13.5-rc1.php @@ -0,0 +1,45 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + */ + +namespace Piwik\Updates; + +use Piwik\DataAccess\ArchiveTableCreator; +use Piwik\Date; +use Piwik\Plugins\CoreAdminHome\Tasks\ArchivesToPurgeDistributedList; +use Piwik\Updater; +use Piwik\Updates as PiwikUpdates; + +class Updates_3_13_5_rc1 extends PiwikUpdates +{ + public function doUpdate(Updater $updater) + { + $this->addArchivesToPurge(); + } + + private function addArchivesToPurge() + { + $archivesToPurge = new ArchivesToPurgeDistributedList(); + + $startOfProblem = Date::factory('2020-01-01 00:00:00'); + + $archiveTables = ArchiveTableCreator::getTablesArchivesInstalled(ArchiveTableCreator::NUMERIC_TABLE); + foreach ($archiveTables as $table) { + $date = ArchiveTableCreator::getDateFromTableName($table); + list($year, $month) = explode('_', $date); + + // only add if the table is for jan 2020 or above since tables w/ that date will be most affected + $dateObj = Date::factory("$year-$month-01 00:00:00"); + if ($dateObj->isEarlier($startOfProblem)) { + continue; + } + + $archivesToPurge->add("{$year}_{$month}"); + } + } +}
\ No newline at end of file diff --git a/core/Version.php b/core/Version.php index d04c036558..fc0bcae937 100644 --- a/core/Version.php +++ b/core/Version.php @@ -20,7 +20,7 @@ final class Version * The current Matomo version. * @var string */ - const VERSION = '3.13.5-b2'; + const VERSION = '3.13.5-rc1'; public function isStableVersion($version) { diff --git a/plugins/CoreAdminHome/Tasks.php b/plugins/CoreAdminHome/Tasks.php index ad81187aa8..ff3ae6497f 100644 --- a/plugins/CoreAdminHome/Tasks.php +++ b/plugins/CoreAdminHome/Tasks.php @@ -252,11 +252,30 @@ class Tasks extends \Piwik\Plugin\Tasks public function purgeInvalidatedArchives() { + $purgedDates = []; + $archivesToPurge = new ArchivesToPurgeDistributedList(); foreach ($archivesToPurge->getAllAsDates() as $date) { $this->archivePurger->purgeInvalidatedArchivesFrom($date); $archivesToPurge->removeDate($date); + + $purgedDates[$date->toString('Y-m')] = true; + } + + // purge from today if not done already since we will have many archives to remove + $today = Date::today(); + $todayStr = $today->toString('Y-m'); + if (empty($purgedDates[$todayStr])) { + $this->archivePurger->purgeInvalidatedArchivesFrom($today); + $purgedDates[$todayStr] = true; + } + + // handle yesterday if it belongs to a different month + $yesterday = Date::yesterday(); + $yesterdayStr = $yesterday->toString('Y-m'); + if (empty($purgedDates[$yesterdayStr])) { + $this->archivePurger->purgeInvalidatedArchivesFrom($yesterday); } } |