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:
authordiosmosis <benaka@piwik.pro>2015-03-19 09:34:42 +0300
committerdiosmosis <benaka@piwik.pro>2015-03-19 09:35:34 +0300
commit04de8d4660056ec9dc655ef99dd65c8266ecd706 (patch)
tree5a6b1fe4e1b3b83a296685a33fb5ef7923bdc70e
parent5447bd01639347c7ee88f7328d65b43d1935c206 (diff)
When segment creation time (or just earliest archive date) is greater than end date of requested range to archive, use end date as override for start of archiving request range.
-rw-r--r--core/CronArchive/SegmentArchivingRequestUrlProvider.php11
-rw-r--r--tests/PHPUnit/Unit/CronArchive/SegmentArchivingRequestUrlProviderTest.php15
2 files changed, 25 insertions, 1 deletions
diff --git a/core/CronArchive/SegmentArchivingRequestUrlProvider.php b/core/CronArchive/SegmentArchivingRequestUrlProvider.php
index fcd1dd8d10..ddbaef0198 100644
--- a/core/CronArchive/SegmentArchivingRequestUrlProvider.php
+++ b/core/CronArchive/SegmentArchivingRequestUrlProvider.php
@@ -65,7 +65,16 @@ class SegmentArchivingRequestUrlProvider
// use the minimum allowed date as the start date
$periodObj = PeriodFactory::build($period, $date);
if ($periodObj->getDateStart()->getTimestamp() < $oldestDateToProcessForNewSegment->getTimestamp()) {
- $date = $oldestDateToProcessForNewSegment->toString().','.$periodObj->getDateEnd();
+ $endDate = $periodObj->getDateEnd();
+
+ // if the creation time of a segment is older than the end date of the archiving request range, we cannot
+ // blindly rewrite the date string, since the resulting range would be incorrect. instead we make the
+ // start date equal to the end date, so less archiving occurs, and no fatal error occurs.
+ if ($oldestDateToProcessForNewSegment->getTimestamp() > $endDate->getTimestamp()) {
+ $oldestDateToProcessForNewSegment = $endDate;
+ }
+
+ $date = $oldestDateToProcessForNewSegment->toString().','.$endDate;
}
return $date;
diff --git a/tests/PHPUnit/Unit/CronArchive/SegmentArchivingRequestUrlProviderTest.php b/tests/PHPUnit/Unit/CronArchive/SegmentArchivingRequestUrlProviderTest.php
index b564f6acdc..e3d36ea9dc 100644
--- a/tests/PHPUnit/Unit/CronArchive/SegmentArchivingRequestUrlProviderTest.php
+++ b/tests/PHPUnit/Unit/CronArchive/SegmentArchivingRequestUrlProviderTest.php
@@ -59,6 +59,12 @@ class SegmentArchivingRequestUrlProviderTest extends \PHPUnit_Framework_TestCase
'ts_created' => '2011-01-01',
'definition' => 'countryCode==ca',
'enable_only_idsite' => 0
+ ),
+
+ array(
+ 'ts_created' => '2015-03-01',
+ 'definition' => 'pageUrl==a',
+ 'enable_only_idsite' => 1
)
);
}
@@ -159,6 +165,15 @@ class SegmentArchivingRequestUrlProviderTest extends \PHPUnit_Framework_TestCase
'countryCode==us',
"2015-02-19,2015-03-01"
),
+
+ array( // test when creation_time is greater than date range end date
+ 'creation_time',
+ 1,
+ '2010-02-01,2015-02-22',
+ 'week',
+ 'pageUrl==a',
+ '2015-02-22,2015-02-22'
+ ),
);
}