WordPress.org

Make WordPress Core

Changeset 37272


Ignore:
Timestamp:
04/21/2016 09:08:11 AM (4 years ago)
Author:
ocean90
Message:

Upgrader: Clear plugin/theme caches directly after a plugin/theme has been updated.

wp_update_plugins() and wp_update_themes() are both hooked into upgrader_process_complete with priority 10. But at this stage the caches in get_plugins(), search_theme_directories(), and wp_get_themes() aren't refreshed yet so both functions couldn't fetch any translations for the new plugin/theme.
To reset the caches, wp_clean_themes_cache() and wp_clean_plugins_cache() are now hooked into upgrader_process_complete with priority 9.

This is a follow-up to [34751].

See #34029.
Fixes #36383.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-upgrader.php

    r36995 r37272  
    977977        add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4);
    978978        //'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.
     979        // Clear cache so wp_update_plugins() knows about the new plugin.
     980        add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 );
    979981
    980982        $this->run( array(
     
    991993
    992994        // Cleanup our hooks, in case something else does a upgrade on this connection.
     995        remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 );
    993996        remove_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade'));
    994997        remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'));
     
    10331036
    10341037        add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4);
     1038        add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 );
    10351039
    10361040        $this->skin->header();
     
    11271131
    11281132        // Cleanup our hooks, in case something else does a upgrade on this connection.
     1133        remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 );
    11291134        remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'));
    11301135
     
    15451550        add_filter('upgrader_post_install', array($this, 'current_after'), 10, 2);
    15461551        add_filter('upgrader_clear_destination', array($this, 'delete_old_theme'), 10, 4);
     1552        // Clear cache so wp_update_themes() knows about the new theme.
     1553        add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 );
    15471554
    15481555        $this->run( array(
     
    15581565        ) );
    15591566
     1567        remove_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9 );
    15601568        remove_filter('upgrader_pre_install', array($this, 'current_before'));
    15611569        remove_filter('upgrader_post_install', array($this, 'current_after'));
     
    16021610        add_filter('upgrader_post_install', array($this, 'current_after'), 10, 2);
    16031611        add_filter('upgrader_clear_destination', array($this, 'delete_old_theme'), 10, 4);
     1612        // Clear cache so wp_update_themes() knows about the new theme.
     1613        add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 );
    16041614
    16051615        $this->skin->header();
     
    16781688
    16791689        // Cleanup our hooks, in case something else does a upgrade on this connection.
     1690        remove_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9 );
    16801691        remove_filter('upgrader_pre_install', array($this, 'current_before'));
    16811692        remove_filter('upgrader_post_install', array($this, 'current_after'));
Note: See TracChangeset for help on using the changeset viewer.