Make WordPress Core

Ticket #5389: cache_suspend.diff

File cache_suspend.diff, 2.3 KB (added by ryan, 18 years ago)
  • wp-includes/cache.php

     
    4343        return $wp_object_cache->replace($key, $data, $flag, $expire);
    4444}
    4545
     46function wp_cache_resume() {
     47        global $wp_object_cache;
     48
     49        $wp_object_cache->cache_suspended = false;
     50}
     51
    4652function wp_cache_set($key, $data, $flag = '', $expire = 0) {
    4753        global $wp_object_cache;
    4854        $data = unserialize(serialize($data));
     
    5056        return $wp_object_cache->set($key, $data, $flag, $expire);
    5157}
    5258
     59function wp_cache_suspend() {
     60        global $wp_object_cache;
     61
     62        $wp_object_cache->cache_suspended = true;
     63}
     64
    5365define('CACHE_SERIAL_HEADER', "<?php\n/*");
    5466define('CACHE_SERIAL_FOOTER', "*/\n?".">");
    5567
    5668class WP_Object_Cache {
    5769        var $cache_dir;
    5870        var $cache_enabled = false;
     71        var $cache_suspended = false;
    5972        var $expiration_time = 900;
    6073        var $flock_filename = 'wp_object_cache.lock';
    6174        var $mutex;
     
    120133        }
    121134
    122135        function get($id, $group = 'default', $count_hits = true) {
     136                if ( $this->cache_suspended )
     137                        return false;
     138
    123139                if (empty ($group))
    124140                        $group = 'default';
    125141
     
    264280        }
    265281
    266282        function set($id, $data, $group = 'default', $expire = '') {
     283                if ( $this->cache_suspended )
     284                        return true;
     285
    267286                if (empty ($group))
    268287                        $group = 'default';
    269288
  • wp-admin/includes/upgrade.php

     
    1111
    1212        wp_check_mysql_version();
    1313        wp_cache_flush();
     14        wp_cache_suspend();
    1415        make_db_current_silent();
    1516        populate_options();
    1617        populate_roles();
     
    5051
    5152        wp_new_blog_notification($blog_title, $guessurl, $user_id, $random_password);
    5253
    53         wp_cache_flush();
    54 
    5554        return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password);
    5655}
    5756endif;
  • wp-admin/admin.php

     
    9797        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    9898
    9999        define('WP_IMPORTING', true);
     100        wp_cache_suspend();
    100101
    101102        call_user_func($wp_importers[$importer][2]);
    102103