Opened 10 years ago
Last modified 5 years ago
#28694 new enhancement
Provide a clean way for Plugins to run update scripts for MultiSite
Reported by: | MadtownLems | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.9.1 |
Component: | Networks and Sites | Keywords: | |
Focuses: | multisite | Cc: |
Description
It's commonly accepted that, if a plugin needs to run a script after updating (such as to modify the database or its settings stored within), that it should do so hooking into admin_init, checking its version number against a database-stored version number, and making adjustments if needed. This works relatively well for single site, only temporarily failing when the plugin is updated through SVN /ftp, and immediately being addressed as soon as any dashboard page is visited.
However, this can often be a much larger issue in MultiSite.
In many MultiSite instances, there will be sites who won't have their dashboards logged into for extended periods of time (sometimes even years), meaning that using admin_init to check for running such an update is impractical.
While hooking onto admin_init AND init would likely solve the issue, it feels like an excessive amount of additional processing (by EVERY plugin on EVERY page load).
I believe that this is an issue that MultiSite needs to address, as currently, plugin authors who use the suggested admin_init method to maybe_update are at risk of major failings in sites using their plugins as part of a network.
(The closest related ticket I found was https://core.trac.wordpress.org/ticket/14912, and it's 4 years old and has no mention of the more serious MultiSite implications.)
Another thing worth noting, if you have to use
switch_to_blog()
or are otherwise pulling data from other sites on the network: If the other site isn't updated, strange things could happen. Of course, this is an edge case that could be covered in the plugin code. It's just another example of the things a developer has to watch out for when performing database updates on multisite.