diff options
author | Peter Zhang <peter@innocraft.com> | 2021-10-08 03:50:21 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-08 03:50:21 +0300 |
commit | b9ba1e58d076708ccab251428b6d4d7a12ab3dc2 (patch) | |
tree | ddf32d387e169f4b4a8d548e0bc1074cda418c5f | |
parent | 41b79fe4dbd179338df22c90f2a44aa7c63b4183 (diff) |
scheduled tasks should not launch archiving when browser archiving is disabled (#18101)
-rw-r--r-- | core/ArchiveProcessor/Rules.php | 9 | ||||
-rw-r--r-- | core/CronArchive.php | 3 | ||||
-rw-r--r-- | plugins/CoreAdminHome/Tasks.php | 2 | ||||
-rw-r--r-- | plugins/CoreAdminHome/tests/Integration/TasksTest.php | 6 |
4 files changed, 12 insertions, 8 deletions
diff --git a/core/ArchiveProcessor/Rules.php b/core/ArchiveProcessor/Rules.php index cd7ef3e394..ceea8ae1b5 100644 --- a/core/ArchiveProcessor/Rules.php +++ b/core/ArchiveProcessor/Rules.php @@ -19,6 +19,7 @@ use Piwik\Option; use Piwik\Piwik; use Piwik\Plugin\Manager; use Piwik\Plugins\CoreAdminHome\Controller; +use Piwik\Scheduler\Task; use Piwik\Segment; use Piwik\SettingsPiwik; use Piwik\SettingsServer; @@ -40,6 +41,10 @@ class Rules /** Flag that will forcefully disable the archiving process (used in tests only) */ public static $archivingDisabledByTests = false; + /** To disable the Pure Outdated Archive set this to true will skip this task */ + public static $disablePureOutdatedArchive = false; + + /** * Returns the name of the archive field used to tell the status of an archive, (ie, * whether the archive was created successfully or not). @@ -69,11 +74,11 @@ class Rules if ($segment->isEmpty() && ($periodLabel != 'range' || SettingsServer::isArchivePhpTriggered())) { return true; } - + if ($periodLabel === 'range' && !SettingsServer::isArchivePhpTriggered()) { return false; } - + return self::isSegmentPreProcessed($idSites, $segment); } diff --git a/core/CronArchive.php b/core/CronArchive.php index e8e287d9ae..bbdd8a691b 100644 --- a/core/CronArchive.php +++ b/core/CronArchive.php @@ -622,7 +622,8 @@ class CronArchive // runs // - setting a new DI environment for core:archive which CoreAdminHome can use to conditionally // enable/disable the task - $_GET['trigger'] = 'archivephp'; + Rules::$disablePureOutdatedArchive = true; + CoreAdminHomeAPI::getInstance()->runScheduledTasks(); $this->logSection(""); diff --git a/plugins/CoreAdminHome/Tasks.php b/plugins/CoreAdminHome/Tasks.php index 0adfb63973..803880b621 100644 --- a/plugins/CoreAdminHome/Tasks.php +++ b/plugins/CoreAdminHome/Tasks.php @@ -233,7 +233,7 @@ class Tasks extends \Piwik\Plugin\Tasks */ public function purgeOutdatedArchives() { - if ($this->willPurgingCausePotentialProblemInUI()) { + if ($this->willPurgingCausePotentialProblemInUI() && !Rules::$disablePureOutdatedArchive) { $this->logger->info("Purging temporary archives: skipped (browser triggered archiving not enabled & not running after core:archive)"); return false; } diff --git a/plugins/CoreAdminHome/tests/Integration/TasksTest.php b/plugins/CoreAdminHome/tests/Integration/TasksTest.php index 9edcbc5fcc..06765ef54d 100644 --- a/plugins/CoreAdminHome/tests/Integration/TasksTest.php +++ b/plugins/CoreAdminHome/tests/Integration/TasksTest.php @@ -79,7 +79,7 @@ class TasksTest extends IntegrationTestCase public function tearDown(): void { - unset($_GET['trigger']); + Rules::$disablePureOutdatedArchive = false; parent::tearDown(); } @@ -103,8 +103,6 @@ class TasksTest extends IntegrationTestCase public function test_purgeOutdatedArchives_SkipsPurging_WhenBrowserArchivingDisabled_AndCronArchiveTriggerNotPresent() { Rules::setBrowserTriggerArchiving(false); - unset($_GET['trigger']); - $wasPurged = $this->tasks->purgeOutdatedArchives(); $this->assertFalse($wasPurged); } @@ -112,7 +110,7 @@ class TasksTest extends IntegrationTestCase public function test_purgeOutdatedArchives_Purges_WhenBrowserArchivingEnabled_AndCronArchiveTriggerPresent() { Rules::setBrowserTriggerArchiving(false); - $_GET['trigger'] = 'archivephp'; + Rules::$disablePureOutdatedArchive = true; $wasPurged = $this->tasks->purgeOutdatedArchives(); $this->assertTrue($wasPurged); |