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:
authordizzy <diosmosis@users.noreply.github.com>2021-03-24 18:18:20 +0300
committerGitHub <noreply@github.com>2021-03-24 18:18:20 +0300
commiteb1a6ba1ff8a0a486f963eb4087714e94a9a4d12 (patch)
treed396bd23cebf1409d37ad9fd1f8b7e863a60f5fe
parent2b35b46a0988f8c3b6f848c59be8d7d918965a52 (diff)
make sure no rearchiving happens if INI config setting is set to 0 or last0 + add extra sanity check. (#17386)
-rw-r--r--core/Archive/ArchiveInvalidator.php8
-rw-r--r--tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php24
2 files changed, 32 insertions, 0 deletions
diff --git a/core/Archive/ArchiveInvalidator.php b/core/Archive/ArchiveInvalidator.php
index 3e8f84775e..5d34ea826c 100644
--- a/core/Archive/ArchiveInvalidator.php
+++ b/core/Archive/ArchiveInvalidator.php
@@ -476,6 +476,10 @@ class ArchiveInvalidator
$earliestDateToRearchive = $this->getEarliestDateToRearchive();
if (empty($startDate)) {
+ if (empty($earliestDateToRearchive)) {
+ return null; // INI setting set to 0 months so no rearchiving
+ }
+
$startDate = $earliestDateToRearchive;
} else if (!empty($earliestDateToRearchive)) {
// don't allow archiving further back than the rearchive_reports_in_past_last_n_months date allows
@@ -803,6 +807,10 @@ class ArchiveInvalidator
}
}
+ if ($lastNMonthsToInvalidate <= 0) {
+ return null;
+ }
+
return Date::yesterday()->subMonth($lastNMonthsToInvalidate)->setDay(1);
}
}
diff --git a/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php b/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php
index 7325ca852e..a8fb31069d 100644
--- a/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php
+++ b/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php
@@ -84,6 +84,30 @@ class ArchiveInvalidatorTest extends IntegrationTestCase
$this->invalidator = new ArchiveInvalidator(new Model(), StaticContainer::get(ArchivingStatus::class), new NullLogger());
}
+ public function test_reArchiveReport_doesNothingIfIniSettingSetToZero()
+ {
+ Date::$now = strtotime('2020-06-16 12:00:00');
+
+ Config::getInstance()->General['rearchive_reports_in_past_last_n_months'] = 'last0';
+
+ $this->invalidator->reArchiveReport([1], 'VisitsSummary', 'some.Report');
+
+ $expectedInvalidations = [];
+ $actualInvalidations = $this->getInvalidatedArchiveTableEntriesSummary();
+
+ $this->assertEquals($expectedInvalidations, $actualInvalidations);
+
+ // different format
+ Config::getInstance()->General['rearchive_reports_in_past_last_n_months'] = '0';
+
+ $this->invalidator->reArchiveReport([1], 'VisitsSummary', 'some.Report');
+
+ $expectedInvalidations = [];
+ $actualInvalidations = $this->getInvalidatedArchiveTableEntriesSummary();
+
+ $this->assertEquals($expectedInvalidations, $actualInvalidations);
+ }
+
public function test_removeInvalidationsFromDistributedList_removesEntriesFromList_WhenNoPluginSpecified()
{
$this->invalidator->scheduleReArchiving([1,2,3], 'ExamplePlugin');