From e39c43ad6c576f3339848b539385459b02e94545 Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Mon, 24 Nov 2014 22:50:22 +0000 Subject: [PATCH] Clear update caches when site language is changed. The update screen has a re-install button which could show the wrong language locale after the site language was changed. That's because the update data is cached. Introduce `_wp_clear_update_cache()` as a helper function to clean up the update cache. props SergeyBiryukov, ocean90. fixes #30369. Built from https://develop.svn.wordpress.org/trunk@30554 git-svn-id: http://core.svn.wordpress.org/trunk@30543 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-upgrader.php | 8 ++------ wp-includes/update.php | 16 +++++++++++++++- wp-includes/version.php | 2 +- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/wp-admin/includes/class-wp-upgrader.php b/wp-admin/includes/class-wp-upgrader.php index 3a3cd69dc0..cfb2e3ab40 100644 --- a/wp-admin/includes/class-wp-upgrader.php +++ b/wp-admin/includes/class-wp-upgrader.php @@ -1372,9 +1372,7 @@ class Language_Pack_Upgrader extends WP_Upgrader { remove_filter( 'upgrader_source_selection', array( $this, 'check_package' ) ); if ( $parsed_args['clear_update_cache'] ) { - wp_clean_themes_cache( true ); - wp_clean_plugins_cache( true ); - delete_site_transient( 'update_core' ); + _wp_clear_update_cache(); } return $results; @@ -2217,9 +2215,7 @@ class WP_Automatic_Updater { } // Clear existing caches - wp_clean_plugins_cache(); - wp_clean_themes_cache(); - delete_site_transient( 'update_core' ); + _wp_clear_update_cache(); wp_version_check(); // check for Core updates wp_update_themes(); // Check for Theme updates diff --git a/wp-includes/update.php b/wp-includes/update.php index bb3b100935..9a46823ce4 100644 --- a/wp-includes/update.php +++ b/wp-includes/update.php @@ -648,8 +648,20 @@ function wp_schedule_update_checks() { } } -if ( ( ! is_main_site() && ! is_network_admin() ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) +/** + * Clear existing update caches for plugins, themes, and core. + * + * @since 4.1.0 + */ +function _wp_clear_update_cache() { + wp_clean_plugins_cache(); + wp_clean_themes_cache(); + delete_site_transient( 'update_core' ); +} + +if ( ( ! is_main_site() && ! is_network_admin() ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { return; +} add_action( 'admin_init', '_maybe_update_core' ); add_action( 'wp_version_check', 'wp_version_check' ); @@ -669,6 +681,8 @@ add_action( 'admin_init', '_maybe_update_themes' ); add_action( 'wp_update_themes', 'wp_update_themes' ); add_action( 'upgrader_process_complete', 'wp_update_themes', 10, 0 ); +add_action( 'update_option_WPLANG', '_wp_clear_update_cache' , 10, 0 ); + add_action( 'wp_maybe_auto_update', 'wp_maybe_auto_update' ); add_action('init', 'wp_schedule_update_checks'); diff --git a/wp-includes/version.php b/wp-includes/version.php index 70f6187b5e..0a9b0e619d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.1-beta2-30553'; +$wp_version = '4.1-beta2-30554'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.