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

Fix for unexpected zero value last edit dates in segment archiving #21189

Merged
merged 4 commits into from
Aug 29, 2023
Merged
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
14 changes: 11 additions & 3 deletions core/CronArchive/SegmentArchiving.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,14 @@ public function getReArchiveSegmentStartDate($segmentInfo)
}
}

private function getCreatedTimeOfSegment($storedSegment)
/**
* Retrieve the created and last edited time as date objects from the supplied segment array
*
* @param array $storedSegment
*
* @return array
*/
private function getCreatedTimeOfSegment(array $storedSegment): array
{
// check for an earlier ts_created timestamp
$createdTime = empty($storedSegment['ts_created']) ? null : Date::factory($storedSegment['ts_created']);
Expand All @@ -185,9 +192,10 @@ private function getCreatedTimeOfSegment($storedSegment)
}

// check for a later ts_last_edit timestamp
$lastEditTime = empty($storedSegment['ts_last_edit']) ? null : Date::factory($storedSegment['ts_last_edit']);
$lastEditTime = empty($storedSegment['ts_last_edit']) || $storedSegment['ts_last_edit'] === '0000-00-00 00:00:00'
? null : Date::factory($storedSegment['ts_last_edit']);

return array($createdTime, $lastEditTime);
return [$createdTime, $lastEditTime];
}

private function getEarliestVisitTimeFor($idSite)
Expand Down
14 changes: 14 additions & 0 deletions tests/PHPUnit/Integration/CronArchive/SegmentArchivingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,20 @@ public function getTestDataForGetReArchiveSegmentStartDate()
'2020-04-13',
],

// creation time, last edit time is 0000-00-00,
[
SegmentArchiving::CREATION_TIME,
['ts_created' => '2020-04-12 03:34:55', 'ts_last_edit' => '0000-00-00 00:00:00'],
'2020-04-12',
],

// last edit time, last edit time is 0000-00-00
[
SegmentArchiving::LAST_EDIT_TIME,
['ts_created' => '2020-04-12 03:34:55', 'ts_last_edit' => '0000-00-00 00:00:00'],
null,
],

// last edit time, no edit time in segment
[
SegmentArchiving::LAST_EDIT_TIME,
Expand Down
Loading