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

Keep track of last activate/deactivate date for plugins #16683

Merged
merged 6 commits into from Nov 10, 2020

Conversation

diosmosis
Copy link
Member

@diosmosis diosmosis commented Nov 9, 2020

Description:

Refs #16396

Stores the last time of activation/deactivation of plugins for use in other plugins. Also includes a change capping the amount of dates that are rearchived if a custom date is supplied.

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
  • 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 9, 2020
@diosmosis diosmosis added this to the 4.0.0-RC milestone Nov 9, 2020
$startDate = $earliestDateToRearchive;
} else if (!empty($earliestDateToRearchive)) {
// don't allow archiving further back than the rearchive_reports_in_past_last_n_months date allows
$startDate = $startDate->isEarlier($earliestDateToRearchive) ? $earliestDateToRearchive : $startDate;
Copy link
Member

Choose a reason for hiding this comment

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

Does that mean there won't be any possibility to rearchive specific reports for dates older than rearchive_reports_in_past_last_n_months? Wondering if there might be any use cases where it might make sense to force that somehow. But guess would be enough to implement it if we have such a use case at some point

Copy link
Member

Choose a reason for hiding this comment

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

I guess a user could always configure it differently above setting.

Copy link
Member Author

Choose a reason for hiding this comment

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

For this a plugin could manually invalidate, since rearchiveRepors is really just a smart wrapper for markArchivesAsInvalidated.

Copy link
Member

Choose a reason for hiding this comment

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

👍

core/Plugin/Manager.php Show resolved Hide resolved
* @return Date|null
* @throws \Exception
*/
public function getPluginLastActivationTime($pluginName)
Copy link
Member

Choose a reason for hiding this comment

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

not any important but could move this methods to the Plugin class so things would maybe feel a bit more natural like $plugin->getLastActivationTime(). Not sure that works though in our context maybe we need to have this information when the plugin is not loaded yet or unloaded already or so. Feel free to ignore

$startDate = $earliestDateToRearchive;
} else if (!empty($earliestDateToRearchive)) {
// don't allow archiving further back than the rearchive_reports_in_past_last_n_months date allows
$startDate = $startDate->isEarlier($earliestDateToRearchive) ? $earliestDateToRearchive : $startDate;
Copy link
Member

Choose a reason for hiding this comment

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

I guess a user could always configure it differently above setting.

@diosmosis
Copy link
Member Author

@tsteur applied changes

core/Plugin.php Outdated
* @return Date|null
* @throws \Exception
*/
public function getPluginLastActivationTime($pluginName)
Copy link
Member

Choose a reason for hiding this comment

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

@diosmosis could rename it to getLastActivationTime() and remove the $pluginName and instead use $this->pluginName?

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

@tsteur
Copy link
Member

tsteur commented Nov 10, 2020

👍 looks good to me. Left one comment though and didn't really test it. @sgiehl maybe you could give it a test?

Copy link
Member

@sgiehl sgiehl left a comment

Choose a reason for hiding this comment

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

Storing those values works as expected.

{
$optionName = self::LAST_PLUGIN_DEACTIVATION_TIME_OPTION_PREFIX . $pluginName;
Option::set($optionName, time());
}
Copy link
Member

Choose a reason for hiding this comment

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

Should we clean up those entries whenever a plugin gets completely uninstalled?

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 might still be useful to know when the plugin was last there... might be more useful to know when it was installed/uninstalled. What do you think @tsteur?

Copy link
Member

Choose a reason for hiding this comment

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

No preference here. Might be useful though to keep them and I can't think of some downside when keeping these entries.

@tsteur tsteur merged commit c65e3b7 into 4.x-dev Nov 10, 2020
@tsteur tsteur deleted the keep-track-of-last-activate-deactivate-date branch November 10, 2020 19:35
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