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

Add convenience method for rescheduling archiving for a single plugin. #16727

Merged
merged 3 commits into from Nov 18, 2020

Conversation

diosmosis
Copy link
Member

Description:

Add new method Plugin::schedulePluginReArchiving() to allow rescheduling archiving for a plugin.

Review

  • Functional review done
  • Usability review done (is anything maybe unclear or think about anything that would cause people to reach out to support)
  • Security review done see checklist
  • Code review done
  • Tests were added if useful/possible
  • Reviewed for breaking changes
  • Developer changelog updated if needed
  • Documentation added if needed
  • Existing documentation updated if needed

@diosmosis diosmosis added the Needs Review PRs that need a code review label Nov 17, 2020
@diosmosis diosmosis added this to the 4.0.0-RC milestone Nov 17, 2020
if (empty($lastCronArchiveTime)) {
$dateTime = $lastDeactivationTime;
} else if (empty($lastDeactivationTime)) {
$dateTime = Date::factory($lastCronArchiveTime);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@diosmosis if Option::get(CronArchive::OPTION_ARCHIVING_FINISHED_TS); returns false then here it would end up being Date::factory(0) which may cause issues? It would be

The date '1970-01-01' is a date before first website was online. Try date that's after Aug 6, 1991 (timestamp 681436800).: 0

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case the first if branch should be hit (empty($lastCronArchiveTime))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 didn't check but might be good to have a test for it if it's not the case yet

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be covered by the first test case in PluginTest

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I double checked and it does
image

@tsteur tsteur requested a review from sgiehl November 17, 2020 04:00
if (empty($lastCronArchiveTime)) {
$dateTime = $lastDeactivationTime;
} else if (empty($lastDeactivationTime)) {
$dateTime = Date::factory($lastCronArchiveTime);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't $dateTime be null if the plugin had not been deactivated before, so it triggers archiving for all dates in the past? 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@diosmosis correct me if I'm wrong but the rearchive method should then limit it to say max 6 months (or whatever value is configured)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@diosmosis did you have a look at my comment? Still thinking using $lastCronArchiveTime in this case seems wrong.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sgiehl it should then be limited see link above or not? also if lastCronArchiveTime is empty then it would have went in the first if

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But $dateTime is set to the last archiving time, so the reports would be built from that date on, or not?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Assuming it last ran today it would only rearchive today? Is this what you mean? We could set it to null in that case?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sgiehl created #16748 good find 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's not expected for the plugin deactivation time to be unset except in the case of installing a plugin (ie, the normal workflow is deactivate plugin, later activate, which triggers this code). In that case we can just set it to null?

$dateTime = Date::factory($lastCronArchiveTime);
} else {
$lastCronArchiveTime = Date::factory($lastCronArchiveTime);
$dateTime = $lastDeactivationTime->isEarlier($lastCronArchiveTime) ? $lastDeactivationTime : $lastCronArchiveTime;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming that the last archive run time is smaller than the deactivation date, wouldn't it make sense to simply skip calling scheduleReArchiving. As no archives should have been built for any newer dates yet, they should be build with the next archiving process nevertheless, shouldn't they?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last archive run time is not really so reliable. AFAIK it gets updated even if only few archives finish etc but doesn't mean they all finished. I reckon it's fine in worst case to rather rearchive a few days of reports

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they wouldn't because I don't think core:archive will create invalidations for them, but that's another problem I think... @tsteur if core:archive hasn't run for a few days, should we automatically create invalidations for those days? We'd check the last run time and if it's more than just today/yesterday, add more invalidations.

@tsteur
Copy link
Member

tsteur commented Nov 17, 2020

@diosmosis looking through all the comments etc this one looks good to merge for me. Can you confirm?

@diosmosis
Copy link
Member Author

@tsteur will merge

@diosmosis diosmosis merged commit 3dbf7f1 into 4.x-dev Nov 18, 2020
@diosmosis diosmosis deleted the reArchivePluginReports branch November 18, 2020 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants