Changes in trunk/wp-includes/cache.php [3812:3465]
- File:
-
- 1 edited
-
trunk/wp-includes/cache.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/cache.php
r3812 r3465 48 48 } 49 49 50 define('CACHE_SERIAL_HEADER', "<?php\n/ *");51 define('CACHE_SERIAL_FOOTER', " */\n?".">");50 define('CACHE_SERIAL_HEADER', "<?php\n//"); 51 define('CACHE_SERIAL_FOOTER', "\n?".">"); 52 52 53 53 class WP_Object_Cache { … … 65 65 var $warm_cache_hits = 0; 66 66 var $cache_misses = 0; 67 var $secret = '';68 67 69 68 function acquire_lock() { … … 105 104 if ( ! $this->acquire_lock() ) 106 105 return false; 107 106 108 107 $this->rm_cache_dir(); 109 108 $this->cache = array (); 110 109 $this->dirty_objects = array (); 111 110 $this->non_existant_objects = array (); 112 111 113 112 $this->release_lock(); 114 113 … … 144 143 } 145 144 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'; 147 146 if (!file_exists($cache_file)) { 148 147 $this->non_existant_objects[$group][$id] = true; … … 160 159 } 161 160 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))); 163 162 if (false === $this->cache[$group][$id]) 164 163 $this->cache[$group][$id] = ''; … … 173 172 174 173 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 }183 174 } 184 175 … … 191 182 foreach ($dogs as $catt) 192 183 $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 } 193 194 } 194 195 } else … … 248 249 if ($file == '.' or $file == '..') 249 250 continue; 250 251 251 252 if (@ is_dir($dir . DIRECTORY_SEPARATOR . $file)) 252 253 $stack[] = $dir . DIRECTORY_SEPARATOR . $file; … … 332 333 $ids = array_unique($ids); 333 334 foreach ($ids as $id) { 334 $cache_file = $group_dir. $this->hash($id).'.php';335 $cache_file = $group_dir.md5($id.DB_PASSWORD).'.php'; 335 336 336 337 // Remove the cache file if the key is not set. … … 342 343 343 344 $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; 345 346 $fd = @fopen($temp_file, 'w'); 346 347 if ( false === $fd ) { … … 354 355 @ unlink($temp_file); 355 356 else 356 $errors++; 357 $errors++; 357 358 } 358 359 @ chmod($cache_file, $file_perms); … … 363 364 364 365 $this->release_lock(); 365 366 366 367 if ( $errors ) 367 368 return false; … … 400 401 return; 401 402 402 if ( ! defined('ENABLE_CACHE') )403 return;404 405 403 // Disable the persistent cache if safe_mode is on. 406 404 if ( ini_get('safe_mode') && ! defined('ENABLE_CACHE') ) … … 424 422 $this->expiration_time = CACHE_EXPIRATION_TIME; 425 423 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); 432 425 } 433 426 }
Note: See TracChangeset
for help on using the changeset viewer.