Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/cache.php

    r3812 r3465  
    4848}
    4949
    50 define('CACHE_SERIAL_HEADER', "<?php\n/*");
    51 define('CACHE_SERIAL_FOOTER', "*/\n?".">");
     50define('CACHE_SERIAL_HEADER', "<?php\n//");
     51define('CACHE_SERIAL_FOOTER', "\n?".">");
    5252
    5353class WP_Object_Cache {
     
    6565    var $warm_cache_hits = 0;
    6666    var $cache_misses = 0;
    67     var $secret = '';
    6867
    6968    function acquire_lock() {
     
    105104        if ( ! $this->acquire_lock() )
    106105            return false;
    107 
     106       
    108107        $this->rm_cache_dir();
    109108        $this->cache = array ();
    110109        $this->dirty_objects = array ();
    111110        $this->non_existant_objects = array ();
    112 
     111       
    113112        $this->release_lock();
    114113
     
    144143        }
    145144
    146         $cache_file = $this->cache_dir.$this->get_group_dir($group)."/".$this->hash($id).'.php';
     145        $cache_file = $this->cache_dir.$this->get_group_dir($group)."/".md5($id.DB_PASSWORD).'.php';
    147146        if (!file_exists($cache_file)) {
    148147            $this->non_existant_objects[$group][$id] = true;
     
    160159        }
    161160
    162         $this->cache[$group][$id] = unserialize(base64_decode(substr(@ file_get_contents($cache_file), strlen(CACHE_SERIAL_HEADER), -strlen(CACHE_SERIAL_FOOTER))));
     161        $this->cache[$group][$id] = unserialize(substr(@ file_get_contents($cache_file), strlen(CACHE_SERIAL_HEADER), -strlen(CACHE_SERIAL_FOOTER)));
    163162        if (false === $this->cache[$group][$id])
    164163            $this->cache[$group][$id] = '';
     
    173172
    174173        return "{$this->blog_id}/$group";
    175     }
    176 
    177     function hash($data) {
    178         if ( function_exists('hash_hmac') ) {
    179             return hash_hmac('md5', $data, $this->secret);
    180         } else {
    181             return md5($data . $this->secret);
    182         }
    183174    }
    184175
     
    191182                foreach ($dogs as $catt)
    192183                    $this->cache['category'][$catt->cat_ID] = $catt;
     184
     185                foreach ($this->cache['category'] as $catt) {
     186                    $curcat = $catt->cat_ID;
     187                    $fullpath = '/'.$this->cache['category'][$catt->cat_ID]->category_nicename;
     188                    while ($this->cache['category'][$curcat]->category_parent != 0) {
     189                        $curcat = $this->cache['category'][$curcat]->category_parent;
     190                        $fullpath = '/'.$this->cache['category'][$curcat]->category_nicename.$fullpath;
     191                    }
     192                    $this->cache['category'][$catt->cat_ID]->fullpath = $fullpath;
     193                }
    193194            }
    194195        } else
     
    248249                if ($file == '.' or $file == '..')
    249250                    continue;
    250 
     251                   
    251252                if (@ is_dir($dir . DIRECTORY_SEPARATOR . $file))
    252253                    $stack[] = $dir . DIRECTORY_SEPARATOR . $file;
     
    332333            $ids = array_unique($ids);
    333334            foreach ($ids as $id) {
    334                 $cache_file = $group_dir.$this->hash($id).'.php';
     335                $cache_file = $group_dir.md5($id.DB_PASSWORD).'.php';
    335336
    336337                // Remove the cache file if the key is not set.
     
    342343
    343344                $temp_file = tempnam($group_dir, 'tmp');
    344                 $serial = CACHE_SERIAL_HEADER.base64_encode(serialize($this->cache[$group][$id])).CACHE_SERIAL_FOOTER;
     345                $serial = CACHE_SERIAL_HEADER.serialize($this->cache[$group][$id]).CACHE_SERIAL_FOOTER;
    345346                $fd = @fopen($temp_file, 'w');
    346347                if ( false === $fd ) {
     
    354355                        @ unlink($temp_file);
    355356                    else
    356                         $errors++;
     357                        $errors++; 
    357358                }
    358359                @ chmod($cache_file, $file_perms);
     
    363364
    364365        $this->release_lock();
    365 
     366       
    366367        if ( $errors )
    367368            return false;
     
    400401            return;
    401402
    402         if ( ! defined('ENABLE_CACHE') )
    403             return;
    404 
    405403        // Disable the persistent cache if safe_mode is on.
    406404        if ( ini_get('safe_mode') && ! defined('ENABLE_CACHE') )
     
    424422            $this->expiration_time = CACHE_EXPIRATION_TIME;
    425423
    426         if ( defined('WP_SECRET') )
    427             $this->secret = WP_SECRET;
    428         else
    429             $this->secret = DB_PASSWORD . DB_USER . DB_NAME . DB_HOST . ABSPATH;
    430 
    431         $this->blog_id = $this->hash($blog_id);
     424        $this->blog_id = md5($blog_id);
    432425    }
    433426}
Note: See TracChangeset for help on using the changeset viewer.