Opened 12 years ago
Closed 11 years ago
#24496 closed enhancement (fixed)
Plugin_Upgrader::bulk_upgrade() and Theme_Upgrader::bulk_upgrade() sanity checks
Reported by: | jamescollins | Owned by: | dd32 |
---|---|---|---|
Milestone: | 3.7 | Priority: | normal |
Severity: | normal | Version: | 2.9 |
Component: | Upgrade/Install | Keywords: | has-patch 3.7-early |
Focuses: | Cc: |
Description
Currently, the Plugin_Upgrader::bulk_upgrade() and Theme_Upgrader::bulk_upgrade() functions don't perform any checks to make sure at least one plugin/theme is passed to it.
This has the side effect in WordPress Multisite that if the function is called with an empty array being passed to it, then maintenance mode is enabled and disabled even though no plugins or themes are updated.
Background: https://github.com/wp-cli/wp-cli/issues/491
Attachments (5)
Change History (13)
#3
@
12 years ago
A workaround for this has now been implemented in wp-cli, but I think it would be a good idea to implement 24496.2.diff
in core to help prevent problems with other third party code using the plugin/theme upgrader code.
#6
@
11 years ago
Can we return early like that or does footer() still need to be called? If so, a possible alternative is:
$maintenance = ( is_multisite() && ! empty( $plugins ) )
#7
@
11 years ago
Hi @ryan,
If no plugins/themes are selected when using the WordPress admin interface to upgrade, plugins/themes a message of
Please select one or more plugins to update.
or
Please select one or more themes to update.
is displayed (via http://core.trac.wordpress.org/browser/trunk/src/wp-admin/update-core.php#L436), which means the Plugin_Upgrader::bulk_upgrade() and Theme_Upgrader::bulk_upgrade() functions don't get executed at all.
So the only case where an empty array could be passed to the bulk_upgrade() function is via third party code (such as WP CLI), in which case I think it is ok to simply return an empty array and output nothing. 24496.4.diff
does this.
Alternatively, if you think it is still best to output the header/footer information, then my approach in 24496.3.diff
could make sense. I thought an explicit if statement was easier to read and understand compared to your suggested alternative.
My preferred approach is 24496.4.diff
.
It looks like it has been this way since the bulk updater was introduced in v2.9 ([12097]).