Updates: Allow background updates to update multiple plugins/themes in the same request.

Due to the `clear_update_cache` parameter not being respected, update caches were being cleared incorrectly which prevented multiple plugins to be updated at the same time in background updates - failing with a `fs_unavailable` error message.

Fixes #38024

Built from https://develop.svn.wordpress.org/trunk@39211


git-svn-id: http://core.svn.wordpress.org/trunk@39151 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dion Hulse 2016-11-13 09:53:32 +00:00
parent 5f7bbe66d7
commit dd0411161d
3 changed files with 23 additions and 20 deletions

View File

@ -101,8 +101,10 @@ class Plugin_Upgrader extends WP_Upgrader {
$this->install_strings();
add_filter('upgrader_source_selection', array($this, 'check_package') );
// Clear cache so wp_update_plugins() knows about the new plugin.
add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 );
if ( $parsed_args['clear_update_cache'] ) {
// Clear cache so wp_update_plugins() knows about the new plugin.
add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 );
}
$this->run( array(
'package' => $package,
@ -168,8 +170,10 @@ class Plugin_Upgrader extends WP_Upgrader {
add_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade'), 10, 2);
add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4);
//'source_selection' => array($this, 'source_selection'), //there's a trac ticket to move up the directory for zip's which are made a bit differently, useful for non-.org plugins.
// Clear cache so wp_update_plugins() knows about the new plugin.
add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 );
if ( $parsed_args['clear_update_cache'] ) {
// Clear cache so wp_update_plugins() knows about the new plugin.
add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 );
}
$this->run( array(
'package' => $r->package,
@ -227,7 +231,6 @@ class Plugin_Upgrader extends WP_Upgrader {
$current = get_site_transient( 'update_plugins' );
add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4);
add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 );
$this->skin->header();
@ -294,6 +297,9 @@ class Plugin_Upgrader extends WP_Upgrader {
$this->maintenance_mode(false);
// Force refresh of plugin update information.
wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
/** This action is documented in wp-admin/includes/class-wp-upgrader.php */
do_action( 'upgrader_process_complete', $this, array(
'action' => 'update',
@ -307,12 +313,8 @@ class Plugin_Upgrader extends WP_Upgrader {
$this->skin->footer();
// Cleanup our hooks, in case something else does a upgrade on this connection.
remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 );
remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'));
// Force refresh of plugin update information.
wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
return $results;
}

View File

@ -201,8 +201,10 @@ class Theme_Upgrader extends WP_Upgrader {
add_filter('upgrader_source_selection', array($this, 'check_package') );
add_filter('upgrader_post_install', array($this, 'check_parent_theme_filter'), 10, 3);
// Clear cache so wp_update_themes() knows about the new theme.
add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 );
if ( $parsed_args['clear_update_cache'] ) {
// Clear cache so wp_update_themes() knows about the new theme.
add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 );
}
$this->run( array(
'package' => $package,
@ -269,8 +271,10 @@ class Theme_Upgrader extends WP_Upgrader {
add_filter('upgrader_pre_install', array($this, 'current_before'), 10, 2);
add_filter('upgrader_post_install', array($this, 'current_after'), 10, 2);
add_filter('upgrader_clear_destination', array($this, 'delete_old_theme'), 10, 4);
// Clear cache so wp_update_themes() knows about the new theme.
add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 );
if ( $parsed_args['clear_update_cache'] ) {
// Clear cache so wp_update_themes() knows about the new theme.
add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 );
}
$this->run( array(
'package' => $r['package'],
@ -329,8 +333,6 @@ class Theme_Upgrader extends WP_Upgrader {
add_filter('upgrader_pre_install', array($this, 'current_before'), 10, 2);
add_filter('upgrader_post_install', array($this, 'current_after'), 10, 2);
add_filter('upgrader_clear_destination', array($this, 'delete_old_theme'), 10, 4);
// Clear cache so wp_update_themes() knows about the new theme.
add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 );
$this->skin->header();
@ -394,6 +396,9 @@ class Theme_Upgrader extends WP_Upgrader {
$this->maintenance_mode(false);
// Refresh the Theme Update information
wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
/** This action is documented in wp-admin/includes/class-wp-upgrader.php */
do_action( 'upgrader_process_complete', $this, array(
'action' => 'update',
@ -407,14 +412,10 @@ class Theme_Upgrader extends WP_Upgrader {
$this->skin->footer();
// Cleanup our hooks, in case something else does a upgrade on this connection.
remove_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9 );
remove_filter('upgrader_pre_install', array($this, 'current_before'));
remove_filter('upgrader_post_install', array($this, 'current_after'));
remove_filter('upgrader_clear_destination', array($this, 'delete_old_theme'));
// Refresh the Theme Update information
wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
return $results;
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.7-beta3-39210';
$wp_version = '4.7-beta3-39211';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.