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-03-14 23:47:39 +0300
committerGitHub <noreply@github.com>2021-03-14 23:47:39 +0300
commitc742236ec8297d2a5f483c7bf5927660066e70ab (patch)
tree3a79fb4cf199bbd14ab7aeefe72b1b7505e32f52
parent8a8cb6305ef2d92413580ff5cae402d17921f81c (diff)
look for all usable done flag types when checking for existing child periods (#17304)
* look for all usable done flag types when checking for existing child periods * add some tests * add comment
-rw-r--r--core/DataAccess/Model.php8
-rw-r--r--tests/PHPUnit/Integration/DataAccess/ModelTest.php19
2 files changed, 26 insertions, 1 deletions
diff --git a/core/DataAccess/Model.php b/core/DataAccess/Model.php
index 8843055559..113673f034 100644
--- a/core/DataAccess/Model.php
+++ b/core/DataAccess/Model.php
@@ -847,9 +847,15 @@ class Model
while ($date->isEarlier($period->getDateEnd()->addPeriod(1, 'month'))) {
$archiveTable = ArchiveTableCreator::getNumericTable($date);
+ // we look for any archive that can be used to compute this one. this includes invalidated archives, since it is possible
+ // under certain circumstances for them to exist, when archiving a higher period that includes them. the main example being
+ // the GoogleAnalyticsImporter which disallows the recomputation of invalidated archives for imported data, since that would
+ // essentially get rid of the imported data.
+ $usableDoneFlags = [ArchiveWriter::DONE_OK, ArchiveWriter::DONE_INVALIDATED, ArchiveWriter::DONE_PARTIAL, ArchiveWriter::DONE_OK_TEMPORARY];
+
$sql = "SELECT idarchive
FROM `$archiveTable`
- WHERE idsite = ? AND date1 >= ? AND date2 <= ? AND period < ? AND `name` LIKE 'done%' AND `value` = " . ArchiveWriter::DONE_OK . "
+ WHERE idsite = ? AND date1 >= ? AND date2 <= ? AND period < ? AND `name` LIKE 'done%' AND `value` IN (" . implode(', ', $usableDoneFlags) . ")
LIMIT 1";
$bind = [$idSite, $period->getDateStart()->getDatetime(), $period->getDateEnd()->getDatetime(), $period->getId()];
diff --git a/tests/PHPUnit/Integration/DataAccess/ModelTest.php b/tests/PHPUnit/Integration/DataAccess/ModelTest.php
index 5b17bde1df..18fea59e5c 100644
--- a/tests/PHPUnit/Integration/DataAccess/ModelTest.php
+++ b/tests/PHPUnit/Integration/DataAccess/ModelTest.php
@@ -274,6 +274,25 @@ class ModelTest extends IntegrationTestCase
'year',
true,
],
+ [
+ [
+ ['date1' => '2015-04-01', 'date2' => '2015-04-01', 'period' => 1, 'name' => 'done', 'value' => 4],
+ ],
+ 1,
+ '2015-02-04',
+ 'year',
+ true,
+ ],
+ [
+ [
+ ['date1' => '2015-04-01', 'date2' => '2015-04-01', 'period' => 1, 'name' => 'done', 'value' => 5],
+ ['date1' => '2014-04-01', 'date2' => '2014-04-01', 'period' => 1, 'name' => 'done', 'value' => 1],
+ ],
+ 1,
+ '2015-02-04',
+ 'year',
+ true,
+ ],
// range period w/ day child
[