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:
Diffstat (limited to 'core/Archive/ArchiveInvalidator.php')
-rw-r--r--core/Archive/ArchiveInvalidator.php37
1 files changed, 24 insertions, 13 deletions
diff --git a/core/Archive/ArchiveInvalidator.php b/core/Archive/ArchiveInvalidator.php
index 52bc3a23b4..e151f1cdac 100644
--- a/core/Archive/ArchiveInvalidator.php
+++ b/core/Archive/ArchiveInvalidator.php
@@ -460,18 +460,12 @@ class ArchiveInvalidator
{
$date2 = Date::yesterday();
+ $earliestDateToRearchive = $this->getEarliestDateToRearchive();
if (empty($startDate)) {
- $lastNMonthsToInvalidate = Config::getInstance()->General['rearchive_reports_in_past_last_n_months'];
- if (empty($lastNMonthsToInvalidate)) {
- return;
- }
-
- $lastNMonthsToInvalidate = (int) substr($lastNMonthsToInvalidate, 4);
- if (empty($lastNMonthsToInvalidate)) {
- return;
- }
-
- $startDate = $date2->subMonth($lastNMonthsToInvalidate)->setDay(1);
+ $startDate = $earliestDateToRearchive;
+ } else if (!empty($earliestDateToRearchive)) {
+ // don't allow archiving further back than the rearchive_reports_in_past_last_n_months date allows
+ $startDate = $startDate->isEarlier($earliestDateToRearchive) ? $earliestDateToRearchive : $startDate;
}
if ($idSites === 'all') {
@@ -538,11 +532,13 @@ class ArchiveInvalidator
*
* @param int|int[]|'all' $idSites
* @param string $pluginName
+ * @param string|null $report
+ * @param Date|null $startDate
*/
- public function reArchiveReportSafely($idSites, $pluginName)
+ public function reArchiveReportSafely($idSites, string $pluginName, string $report = null, Date $startDate = null)
{
try {
- $this->reArchiveReport($idSites, $pluginName);
+ $this->reArchiveReport($idSites, $pluginName, $report, $startDate);
} catch (\Throwable $ex) {
$logger = StaticContainer::get(LoggerInterface::class);
$logger->info("Failed to schedule rearchiving of past reports for $pluginName plugin.");
@@ -680,4 +676,19 @@ class ArchiveInvalidator
$model = new \Piwik\Plugins\SitesManager\Model();
return $model->getSitesId();
}
+
+ private function getEarliestDateToRearchive()
+ {
+ $lastNMonthsToInvalidate = Config::getInstance()->General['rearchive_reports_in_past_last_n_months'];
+ if (empty($lastNMonthsToInvalidate)) {
+ return null;
+ }
+
+ $lastNMonthsToInvalidate = (int) substr($lastNMonthsToInvalidate, 4);
+ if (empty($lastNMonthsToInvalidate)) {
+ return null;
+ }
+
+ return Date::yesterday()->subMonth($lastNMonthsToInvalidate)->setDay(1);
+ }
}