From f38be98c89d38d62b0f5e5cd6359f55922d06949 Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Mon, 24 Nov 2014 22:49:13 +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. git-svn-id: https://develop.svn.wordpress.org/trunk@30554 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-upgrader.php | 8 ++------ src/wp-includes/update.php | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/wp-admin/includes/class-wp-upgrader.php b/src/wp-admin/includes/class-wp-upgrader.php index 3a3cd69dc0..cfb2e3ab40 100644 --- a/src/wp-admin/includes/class-wp-upgrader.php +++ b/src/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/src/wp-includes/update.php b/src/wp-includes/update.php index bb3b100935..9a46823ce4 100644 --- a/src/wp-includes/update.php +++ b/src/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');