Skip to content
Browse files

Only use maintenance mode if a plugin or theme needs updating

When updating plugins (wp plugin update-all) or themes (wp theme update-all) on a WordPress multisite installation, maintenance activated and deactivated even if there are no updates to install.

The Plugin_Upgrader::bulk_upgrade() and Theme_Upgrader::bulk_upgrade() WordPress functions currently don't check that the array passed to it isn't empty, causing maintenance mode to be enabled even if no updates are required.

This bug doesn't affect non multisite installs, because for non multisite installs the code in Plugin_Upgrader::bulk_upgrade() and Theme_Upgrader::bulk_upgrade() only uses maintenance mode if the plugin/theme being updated is activated.

Fixes #491
  • Loading branch information...
1 parent 03fb31d commit 8491cfbcb4d7c2e6fa093e2fd9c47632eb1648bc @jamesacollins jamesacollins committed Jun 5, 2013
Showing with 2 additions and 1 deletion.
  1. +2 −1 php/WP_CLI/CommandWithUpgrade.php
3 php/WP_CLI/CommandWithUpgrade.php
@@ -179,7 +179,8 @@ function update_all( $args, $assoc_args ) {
$upgrader = \WP_CLI\Utils\get_upgrader( $this->upgrader );
- $result = $upgrader->bulk_upgrade( wp_list_pluck( $items_to_update, 'update_id' ) );
+ $result = count($items_to_update) ? $upgrader->bulk_upgrade( wp_list_pluck( $items_to_update, 'update_id' ) ) : array();
scribu added a note Jun 5, 2013

If you convert the ternary operator to a regular if statement and open a pull request, I'll merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
// Let the user know the results.
$num_to_update = count( $items_to_update );

0 comments on commit 8491cfb

Please sign in to comment.
Something went wrong with that request. Please try again.