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-02-05 01:22:11 +0300
committerGitHub <noreply@github.com>2021-02-05 01:22:11 +0300
commit490dc3a1a09e4263b4893cbbbf600ba505d9add4 (patch)
tree2fca42614fec12907ecac1ae217e1305baa4144a /core/CronArchive.php
parentbc53bc36ebebfe50d83d6ce381aa8bb6cd2cb15c (diff)
Refactor segment re-archiving in past behavior to be on demand (#17005)
* Invalidate past archives on demand when adding/updating segments, rather than trying to check when running core:archive * start on rewriting test * rewrite SegmentArchivingTest and get to pass * get sites as superuser * add update to rearchive segments if they were created/update between last archive time and update time * remove unused parameter * fix build * fix tests * sanity check * fix bug, we should not forget archives to invalidate unless all related archives are being invalidated * fix tests and make fix more complete * fix test * update counts in test * fix test for last time hopefully * fix another test * remove debugging code
Diffstat (limited to 'core/CronArchive.php')
-rw-r--r--core/CronArchive.php34
1 files changed, 4 insertions, 30 deletions
diff --git a/core/CronArchive.php b/core/CronArchive.php
index 067b85e6db..8d634000ba 100644
--- a/core/CronArchive.php
+++ b/core/CronArchive.php
@@ -199,8 +199,6 @@ class CronArchive
*/
private $periodIdsToLabels;
- private $processNewSegmentsFrom;
-
/**
* @var ArchiveFilter
*/
@@ -219,17 +217,13 @@ class CronArchive
/**
* Constructor.
*
- * @param string|null $processNewSegmentsFrom When to archive new segments from. See [General] process_new_segments_from
- * for possible values.
* @param LoggerInterface|null $logger
*/
- public function __construct($processNewSegmentsFrom = null, LoggerInterface $logger = null)
+ public function __construct(LoggerInterface $logger = null)
{
$this->logger = $logger ?: StaticContainer::get('Psr\Log\LoggerInterface');
$this->formatter = new Formatter();
- $this->processNewSegmentsFrom = $processNewSegmentsFrom ?: StaticContainer::get('ini.General.process_new_segments_from');
-
$this->invalidator = StaticContainer::get('Piwik\Archive\ArchiveInvalidator');
$this->isArchiveProfilingEnabled = Config::getInstance()->Debug['archiving_profile'] == 1;
@@ -276,7 +270,7 @@ class CronArchive
public function init()
{
- $this->segmentArchiving = new SegmentArchiving($this->processNewSegmentsFrom, $this->dateLastForced);
+ $this->segmentArchiving = StaticContainer::get(SegmentArchiving::class);
/**
* This event is triggered during initializing archiving.
@@ -567,7 +561,7 @@ class CronArchive
$visits = (int) $visits;
$this->logger->info("Archived website id {$params['idSite']}, period = {$params['period']}, date = "
- . "{$params['date']}, segment = '" . (isset($params['segment']) ? urldecode($params['segment']) : '') . "', "
+ . "{$params['date']}, segment = '" . (isset($params['segment']) ? urldecode(urldecode($params['segment'])) : '') . "', "
. ($plugin ? "plugin = $plugin, " : "") . ($report ? "report = $report, " : "") . "$visits visits found. $timer");
}
@@ -778,7 +772,7 @@ class CronArchive
{
if (empty($this->segmentArchiving)) {
// might not be initialised if init is not called
- $this->segmentArchiving = new SegmentArchiving($this->processNewSegmentsFrom, $this->dateLastForced);
+ $this->segmentArchiving = StaticContainer::get(SegmentArchiving::class);
}
$this->logger->debug("Checking for queued invalidations...");
@@ -838,26 +832,6 @@ class CronArchive
$this->invalidateWithSegments($idSiteToInvalidate, $date, 'range', $_forceInvalidateNonexistant = true);
}
- // for new segments, invalidate past dates
- $segmentDatesToInvalidate = $this->segmentArchiving->getSegmentArchivesToInvalidateForNewSegments($idSiteToInvalidate);
-
- foreach ($segmentDatesToInvalidate as $info) {
- $this->logger->info(' Segment "{segment}" was created or changed recently and will therefore archive today (for site ID = {idSite})', [
- 'segment' => $info['segment'],
- 'idSite' => $idSiteToInvalidate,
- ]);
-
- $earliestDate = $info['date'];
-
- $allDates = PeriodFactory::build('range', $earliestDate . ',today')->getSubperiods();
- $allDates = array_map(function (Period $p) {
- return $p->getDateStart()->toString();
- }, $allDates);
- $allDates = implode(',', $allDates);
-
- $this->getApiToInvalidateArchivedReport()->invalidateArchivedReports($idSiteToInvalidate, $allDates, $period = false, $info['segment']);
- }
-
$this->setInvalidationTime();
$this->logger->debug("Done invalidating");