Make WordPress Core

Ticket #5389: 5389.patch

File 5389.patch, 3.5 KB (added by SergeyBiryukov, 14 years ago)
  • wp-admin/admin.php

     
    202202        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    203203
    204204        define('WP_IMPORTING', true);
     205        wp_cache_suspend();
    205206
    206207        if ( apply_filters( 'force_filtered_html_on_import', false ) )
    207208                kses_init_filters();  // Always filter imported data with kses on multisite.
  • wp-admin/includes/upgrade.php

     
    4242
    4343        wp_check_mysql_version();
    4444        wp_cache_flush();
     45        wp_cache_suspend();
    4546        make_db_current_silent();
    4647        populate_options();
    4748        populate_roles();
     
    8687
    8788        wp_new_blog_notification($blog_title, $guessurl, $user_id, ($email_password ? $user_password : __('The password you chose during the install.') ) );
    8889
    89         wp_cache_flush();
    90 
    9190        return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
    9291}
    9392endif;
     
    362361
    363362        wp_check_mysql_version();
    364363        wp_cache_flush();
     364        wp_cache_suspend();
    365365        pre_schema_upgrade();
    366366        make_db_current_silent();
    367367        upgrade_all();
    368368        if ( is_multisite() && is_main_site() )
    369369                upgrade_network();
    370         wp_cache_flush();
    371370
    372371        if ( is_multisite() ) {
    373372                if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) )
  • wp-includes/cache.php

     
    278278        var $global_groups = array();
    279279
    280280        /**
     281         * If the cache is suspended for performance reasons
     282         *
     283         * @var bool
     284         * @access private
     285         * @since 3.3.0
     286         */
     287        var $cache_suspended = false;
     288
     289        /**
    281290         * Adds data to the cache if it doesn't already exist.
    282291         *
    283292         * @uses WP_Object_Cache::get Checks to see if the cache already has data.
     
    293302         * @return bool False if cache ID and group already exists, true on success
    294303         */
    295304        function add( $id, $data, $group = 'default', $expire = '' ) {
     305                if ( $this->cache_suspended )
     306                        return true;
     307
    296308                if ( empty ($group) )
    297309                        $group = 'default';
    298310
     
    509521         * @return bool Always returns true
    510522         */
    511523        function set($id, $data, $group = 'default', $expire = '') {
     524                if ( $this->cache_suspended )
     525                        return true;
     526
    512527                if ( empty ($group) )
    513528                        $group = 'default';
    514529
  • wp-includes/functions.php

     
    37003700}
    37013701
    37023702/**
     3703 * Suspend object caching.
     3704 *
     3705 * Stops wp_cache_add() from adding objects to the cache. Useful for imports when
     3706 * the huge amount of data being added to cache isn't useful. Call wp_cache_resume() later
     3707 * if you want suspension to only be temporary.
     3708 *
     3709 * @since 3.3.0
     3710*/
     3711function wp_cache_suspend() {
     3712        global $wp_object_cache;
     3713
     3714        if ( !empty( $wp_object_cache ) )
     3715                $wp_object_cache->cache_suspended = true;
     3716}
     3717
     3718/**
     3719 * Resume object caching.
     3720 *
     3721 * @since 3.3.0
     3722 */
     3723function wp_cache_resume() {
     3724        global $wp_object_cache;
     3725
     3726        if ( !empty( $wp_object_cache ) )
     3727                $wp_object_cache->cache_suspended = false;
     3728}
     3729
     3730/**
    37033731 * Suspend cache invalidation.
    37043732 *
    37053733 * Turns cache invalidation on and off.  Useful during imports where you don't wont to do invalidations