Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow invalidation of All Visits only #22989

Open
wants to merge 8 commits into
base: 5.x-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 14 additions & 20 deletions core/Archive/ArchiveInvalidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,14 @@ private function deleteOptionLike($id)
}

/**
* @param $idSites int[]
* @param $dates Date[]|string[]
* @param $period string
* @param $segment Segment
* @param int[] $idSites
* @param Date[]|string[] $dates
* @param string $period
* @param null|Segment $segment
* @param bool $cascadeDown
* @param bool $forceInvalidateNonexistentRanges set true to force inserting rows for ranges in archive_invalidations
* @param string $name null to make sure every plugin is archived when this invalidation is processed by core:archive,
* or a plugin name to only archive the specific plugin.
* @param null|string $name null to make sure every plugin is archived when this invalidation is processed by core:archive,
* or a plugin name to only archive the specific plugin.
* @param bool $ignorePurgeLogDataDate
* @param bool $doNotCreateInvalidations If true, archives will only be marked as invalid, but no archive_invalidation record will be created
* @return InvalidationResult
Expand Down Expand Up @@ -317,7 +317,7 @@ public function markArchivesAsInvalidated(
* @param array &$idSites An array containing a list of site IDs which are requested to be invalidated.
* @param array $dates An array containing the dates to invalidate.
* @param string $period A string containing the period to be invalidated.
* @param Segment $segment A Segment Object containing segment to invalidate.
* @param null|Segment $segment A Segment Object containing segment to invalidate.
* @param string $name A string containing the name of the archive to be invalidated.
* @param bool $isPrivacyDeleteData A boolean value if event is triggered via Privacy delete visit action.
*/
Expand Down Expand Up @@ -434,15 +434,15 @@ private function addParentPeriodsByYearMonth(&$result, Period $period, ?Date $or
}

/**
* @param $idSites int[]
* @param $dates Date[]
* @param $period string
* @param $segment Segment
* @param bool $cascadeDown
* @param int[] $idSites
* @param Date[] $dates
* @param Segment $segment
* @param null|string $name null to make sure every plugin is archived when this invalidation is processed by core:archive,
* * or a plugin name to only archive the specific plugin.
* @return InvalidationResult
* @throws \Exception
*/
public function markArchivesOverlappingRangeAsInvalidated(array $idSites, array $dates, ?Segment $segment = null)
public function markArchivesOverlappingRangeAsInvalidated(array $idSites, array $dates, ?Segment $segment = null, ?string $name = null)
{
$invalidationInfo = new InvalidationResult();

Expand All @@ -451,15 +451,9 @@ public function markArchivesOverlappingRangeAsInvalidated(array $idSites, array
$ranges[] = Period\Factory::build('range', $dateRange[0] . ',' . $dateRange[1]);
}

$invalidatedMonths = array();
$archiveNumericTables = ArchiveTableCreator::getTablesArchivesInstalled($type = ArchiveTableCreator::NUMERIC_TABLE);
foreach ($archiveNumericTables as $table) {
$tableDate = ArchiveTableCreator::getDateFromTableName($table);

$rowsAffected = $this->model->updateArchiveAsInvalidated($table, $idSites, $ranges, $segment);
if ($rowsAffected > 0) {
$invalidatedMonths[] = $tableDate;
}
$this->model->updateArchiveAsInvalidated($table, $idSites, $ranges, $segment, false, $name);
}

foreach ($idSites as $idSite) {
Expand Down
24 changes: 20 additions & 4 deletions core/DataAccess/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,22 @@ public function updateArchiveAsInvalidated(
}
}

$doneFlag = Rules::getDoneFlagArchiveContainsAllPlugins($segment ?: new Segment('', []));

if (empty($plugin)) {
$doneFlag = Rules::getDoneFlagArchiveContainsAllPlugins($segment ?: new Segment('', []));
if (null === $segment) {
$nameCondition = "name LIKE '$doneFlag%'"; // invalidate all segments
} else {
$nameCondition = "(name = '$doneFlag' OR name LIKE '$doneFlag.%')"; // invalidate specific segment only
}
} else {
$doneFlag = Rules::getDoneFlagArchiveContainsOnePlugin($segment ?: new Segment('', []), $plugin);
if (null === $segment) {
$nameCondition = "name LIKE '$doneFlag%.$plugin'"; // invalidate all segments for specific plugin
} else {
$nameCondition = "name = '$doneFlag.$plugin'"; // invalidate specific segment for specific plugin only
}
}

$nameCondition = "name LIKE '$doneFlag%'";

$sql .= " AND $nameCondition";

Expand Down Expand Up @@ -199,7 +208,7 @@ public function updateArchiveAsInvalidated(
}
}

if (true === $doNotCreateInvalidations) {
if ($doNotCreateInvalidations) {
return count($idArchives);
}

Expand All @@ -219,6 +228,13 @@ public function updateArchiveAsInvalidated(
return Segment::getSegmentHash($definition);
}, $hashesOfAllSegmentsToArchiveInCoreArchive);


if (empty($plugin)) {
$doneFlag = Rules::getDoneFlagArchiveContainsAllPlugins($segment ?: new Segment('', []));
} else {
$doneFlag = Rules::getDoneFlagArchiveContainsOnePlugin($segment ?: new Segment('', []), $plugin);
}

$dummyArchives = [];
foreach ($idSites as $idSite) {
try {
Expand Down
Loading
Loading