Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiosmosis <benaka@piwik.pro>2015-08-12 22:40:11 +0300
committerdiosmosis <benaka@piwik.pro>2015-08-12 22:40:11 +0300
commitaf44ee1de20bd2f9ace63e7f69f2312c08cfa61e (patch)
tree7973314f90289c7e4d491357d639a437c78707db /plugins/CoreAdminHome
parent06afd0dbedc00b752be489977fd883ccf90f5ccc (diff)
Make sure purgeOutdatedArchives task is executed in scheduled task run after core:archive run (regression caused by scheduled task execution refactor).
Diffstat (limited to 'plugins/CoreAdminHome')
-rw-r--r--plugins/CoreAdminHome/Tasks.php8
-rw-r--r--plugins/CoreAdminHome/tests/Integration/TasksTest.php26
2 files changed, 33 insertions, 1 deletions
diff --git a/plugins/CoreAdminHome/Tasks.php b/plugins/CoreAdminHome/Tasks.php
index 2fe5a83ed9..01290f0cff 100644
--- a/plugins/CoreAdminHome/Tasks.php
+++ b/plugins/CoreAdminHome/Tasks.php
@@ -51,11 +51,15 @@ class Tasks extends \Piwik\Plugin\Tasks
$this->weekly('updateSpammerBlacklist');
}
+ /**
+ * @return bool `true` if the purge was executed, `false` if it was skipped.
+ * @throws \Exception
+ */
public function purgeOutdatedArchives()
{
if ($this->willPurgingCausePotentialProblemInUI()) {
$this->logger->info("Purging temporary archives: skipped (browser triggered archiving not enabled & not running after core:archive)");
- return;
+ return false;
}
$archiveTables = ArchiveTableCreator::getTablesArchivesInstalled();
@@ -86,6 +90,8 @@ class Tasks extends \Piwik\Plugin\Tasks
$this->logger->info("Skipping purging of archive tables *_{year}_{month}, year <= 1990.", array('year' => $year, 'month' => $month));
}
}
+
+ return true;
}
public function purgeInvalidatedArchives()
diff --git a/plugins/CoreAdminHome/tests/Integration/TasksTest.php b/plugins/CoreAdminHome/tests/Integration/TasksTest.php
index ff4822fbce..1b25833712 100644
--- a/plugins/CoreAdminHome/tests/Integration/TasksTest.php
+++ b/plugins/CoreAdminHome/tests/Integration/TasksTest.php
@@ -8,6 +8,7 @@
namespace Piwik\Plugins\CoreAdminHome\tests\Integration;
use Piwik\Archive\ArchivePurger;
+use Piwik\ArchiveProcessor\Rules;
use Piwik\Date;
use Piwik\Plugins\CoreAdminHome\Tasks;
use Piwik\Plugins\CoreAdminHome\Tasks\ArchivesToPurgeDistributedList;
@@ -55,6 +56,13 @@ class TasksTest extends IntegrationTestCase
$this->tasks = new Tasks($archivePurger, new NullLogger());
}
+ public function tearDown()
+ {
+ unset($_GET['trigger']);
+
+ parent::tearDown();
+ }
+
public function test_purgeInvalidatedArchives_PurgesCorrectInvalidatedArchives_AndOnlyPurgesDataForDatesAndSites_InInvalidatedReportsDistributedList()
{
$this->setUpInvalidatedReportsDistributedList($dates = array($this->february));
@@ -71,6 +79,24 @@ class TasksTest extends IntegrationTestCase
$this->assertEmpty($yearMonths);
}
+ public function test_purgeOutdatedArchives_SkipsPurging_WhenBrowserArchivingDisabled_AndCronArchiveTriggerNotPresent()
+ {
+ Rules::setBrowserTriggerArchiving(false);
+ unset($_GET['trigger']);
+
+ $wasPurged = $this->tasks->purgeOutdatedArchives();
+ $this->assertFalse($wasPurged);
+ }
+
+ public function test_purgeOutdatedArchives_Purges_WhenBrowserArchivingEnabled_AndCronArchiveTriggerPresent()
+ {
+ Rules::setBrowserTriggerArchiving(false);
+ $_GET['trigger'] = 'archivephp';
+
+ $wasPurged = $this->tasks->purgeOutdatedArchives();
+ $this->assertTrue($wasPurged);
+ }
+
/**
* @param Date[] $dates
*/