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
Avoid creating any archive tables for future dates #13504
Conversation
@@ -166,6 +166,9 @@ public static function getArchiveIds($siteIds, $periods, $segment, $plugins) | |||
$monthToPeriods = array(); | |||
foreach ($periods as $period) { | |||
/** @var Period $period */ | |||
if ($period->getDateStart()->isLater(Date::now()->addDay(2))) { | |||
continue; // avoid creating any archive tables in the future | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add this code to ArchiveTableCreator? I can't think of a reason for code to create a table in the future (except possibly tests, though probably not). If some other code uses ArchiveTableCreator directly, this safeguard would be applied there too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it might make sense for some custom plugins to create archives in the future. e.g. for some kind of prediction reports of whatever. Nevertheless the ArchiveSelector shouldn't trigger the creation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
Is it possible to add a test for this? Otherwise looks good to me. |
@diosmosis what shall the test check? That no archive table is created when ArchiveSelector::getNumeicTable is called with a future date? |
That could work. Or a system/integration test that uses a date in the future w/ VisitsSummary.get and has a check that the table wasn't created. |
Test sounds good 👍 then good to merge |
495c326
to
fcc2234
Compare
I've added two simple tests. (Note: The first of the tests would currently fail on 3.x-dev branch, as an archive table is created) |
* Avoid creating any archive tables for future dates * Adds simple tests to prove no future archive tables are created
Under certain circumstances Archiving might create empty
archive_numeric
tables for future dates:enable_browser_archiving_triggering
is set to0
&period=range&date=2018-01-01,2019-09-29