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 08:04:15 +0300
committerGitHub <noreply@github.com>2021-02-05 08:04:15 +0300
commit540ed05cb7ce9680e450eaf9ab83e02745313662 (patch)
tree754e8ac19d62d7f3079f4060d91f5a6be59ee9e0
parenta2fd1e52fa34a241bf3b4d83114863418cf6742a (diff)
Include report column in duplicate check when inserting archive invalidations. (#17192)
* Include report column in duplicate check when inserting archive invalidations. * add test
-rw-r--r--core/DataAccess/Model.php10
-rw-r--r--tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php23
2 files changed, 28 insertions, 5 deletions
diff --git a/core/DataAccess/Model.php b/core/DataAccess/Model.php
index 156cd14e8b..82cec23c06 100644
--- a/core/DataAccess/Model.php
+++ b/core/DataAccess/Model.php
@@ -228,7 +228,7 @@ class Model
$date1 = $period->getDateStart()->toString();
$date2 = $period->getDateEnd()->toString();
- $key = $this->makeExistingInvalidationArrayKey($idSite, $date1, $date2, $period->getId(), $doneFlag);
+ $key = $this->makeExistingInvalidationArrayKey($idSite, $date1, $date2, $period->getId(), $doneFlag, $name);
if (!empty($existingInvalidations[$key])) {
continue; // avoid adding duplicates where possible
}
@@ -262,7 +262,7 @@ class Model
$idSites = array_map('intval', $idSites);
- $sql = "SELECT idsite, date1, date2, period, name, COUNT(*) as `count` FROM `$table`
+ $sql = "SELECT idsite, date1, date2, period, name, report, COUNT(*) as `count` FROM `$table`
WHERE idsite IN (" . implode(',', $idSites) . ") AND status = " . ArchiveInvalidator::INVALIDATION_STATUS_QUEUED . "
$periodCondition AND $nameCondition
GROUP BY idsite, date1, date2, period, name";
@@ -270,15 +270,15 @@ class Model
$invalidations = [];
foreach ($rows as $row) {
- $key = $this->makeExistingInvalidationArrayKey($row['idsite'], $row['date1'], $row['date2'], $row['period'], $row['name']);
+ $key = $this->makeExistingInvalidationArrayKey($row['idsite'], $row['date1'], $row['date2'], $row['period'], $row['name'], $row['report']);
$invalidations[$key] = $row['count'];
}
return $invalidations;
}
- private function makeExistingInvalidationArrayKey($idSite, $date1, $date2, $period, $name)
+ private function makeExistingInvalidationArrayKey($idSite, $date1, $date2, $period, $name, $report)
{
- return implode('.', [$idSite, $date1, $date2, $period, $name]);
+ return implode('.', [$idSite, $date1, $date2, $period, $name, $report]);
}
/**
diff --git a/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php b/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php
index f71d63f54d..0e2ac1f0ca 100644
--- a/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php
+++ b/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php
@@ -1224,12 +1224,17 @@ class ArchiveInvalidatorTest extends IntegrationTestCase
['name' => 'done' . $segmentHash, 'idsite' => 1, 'date1' => '2020-05-10', 'date2' => '2020-05-10', 'period' => 1, 'report' => null],
['name' => 'done' . $segmentHash, 'idsite' => 1, 'date1' => '2020-05-01', 'date2' => '2020-05-31', 'period' => 3, 'report' => null],
+
+ ['name' => 'done' . $segmentHash, 'idsite' => 1, 'date1' => '2020-05-01', 'date2' => '2020-05-31', 'period' => 4, 'report' => 'aReport'],
+ ['name' => 'done' . $segmentHash, 'idsite' => 1, 'date1' => '2020-05-01', 'date2' => '2020-05-31', 'period' => 4, 'report' => 'anotherReport'],
];
$this->insertInvalidations($existingInvalidations);
$archiveInvalidator->markArchivesAsInvalidated([1], ['2020-03-04', '2020-05-06'], 'week',
$segment, $cascadeDown = true, false);
+ $archiveInvalidator->markArchivesAsInvalidated([1], ['2020-05-01'], 'year',
+ $segment, $cascadeDown = false, 'aReport');
$expectedInvalidations = [
array (
@@ -1314,6 +1319,24 @@ class ArchiveInvalidatorTest extends IntegrationTestCase
'report' => NULL,
),
array (
+ 'idarchive' => null,
+ 'idsite' => '1',
+ 'date1' => '2020-05-01',
+ 'date2' => '2020-05-31',
+ 'period' => '4',
+ 'name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc',
+ 'report' => 'aReport',
+ ),
+ array (
+ 'idarchive' => null,
+ 'idsite' => '1',
+ 'date1' => '2020-05-01',
+ 'date2' => '2020-05-31',
+ 'period' => '4',
+ 'name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc',
+ 'report' => 'anotherReport',
+ ),
+ array (
'idarchive' => NULL,
'idsite' => '1',
'date1' => '2020-03-02',