From 4984ad77a24a59739fef258a0c9b14ead7871a13 Mon Sep 17 00:00:00 2001 From: sgiehl Date: Mon, 8 Jul 2024 21:34:54 +0200 Subject: [PATCH] improve check for already processed dependent segments --- core/ArchiveProcessor.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/core/ArchiveProcessor.php b/core/ArchiveProcessor.php index ac837d4f8b1d..61c75b58286d 100644 --- a/core/ArchiveProcessor.php +++ b/core/ArchiveProcessor.php @@ -111,7 +111,7 @@ class ArchiveProcessor private $numberOfVisitsConverted = false; - private $processedDependentSegments = []; + private static $processedDependentSegments = []; public function __construct(Parameters $params, ArchiveWriter $archiveWriter, LogAggregator $logAggregator) { @@ -772,10 +772,9 @@ public function processDependentArchive($plugin, $segment) return; } - // The below check is meant to avoid archiving the VisitsSummary more often than needed - // If e.g. one plugin depends on a certain segment it will process VisitsSummary first. - // So another plugin depending on VisitsSummary for the same segment doesn't need to be processed. - if (in_array($newSegment->getOriginalString(), $this->processedDependentSegments) && $plugin === 'VisitsSummary') { + // The below check is meant to avoid archiving the same dependency multiple times. + $processedSegmentKey = $params->getSite()->getId() . $params->getDateStart() . $params->getPeriod()->getLabel() . $newSegment->getOriginalString(); + if (in_array($processedSegmentKey . $plugin, self::$processedDependentSegments)) { return; } @@ -785,7 +784,7 @@ public function processDependentArchive($plugin, $segment) // Ensure to always invalidate VisitsSummary before any other plugin archive. // Otherwise those archives might get build with outdated VisitsSummary data - if ($plugin !== 'VisitsSummary' && !in_array($newSegment->getOriginalString(), $this->processedDependentSegments)) { + if ($plugin !== 'VisitsSummary' && !in_array($processedSegmentKey . 'VisitsSummary', self::$processedDependentSegments)) { $invalidator->markArchivesAsInvalidated( $idSites, [$params->getDateStart()], @@ -803,6 +802,8 @@ public function processDependentArchive($plugin, $segment) $archiveLoader = new ArchiveProcessor\Loader($parameters); $archiveLoader->prepareArchive('VisitsSummary'); + + self::$processedDependentSegments[] = $processedSegmentKey . 'VisitsSummary'; } $invalidator->markArchivesAsInvalidated( @@ -823,7 +824,7 @@ public function processDependentArchive($plugin, $segment) $archiveLoader = new ArchiveProcessor\Loader($parameters); $archiveLoader->prepareArchive($plugin); - $this->processedDependentSegments[] = $newSegment->getOriginalString(); + self::$processedDependentSegments[] = $processedSegmentKey . $plugin; } finally { self::$isRootArchivingRequest = true; }