Changeset 3019
- Timestamp:
- 11/09/2005 02:38:17 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/cache.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/cache.php
r3018 r3019 45 45 return $wp_object_cache->set($key, $data, $flag, $expire); 46 46 } 47 48 define('CACHE_SERIAL_HEADER', "<?php\n//"); 49 define('CACHE_SERIAL_FOOTER', "\n?".">"); 47 50 48 51 class WP_Object_Cache { … … 106 109 } 107 110 108 $cache_file = $this->cache_dir . $this->get_group_dir($group) . "/" . md5($id . DB_PASSWORD) ;111 $cache_file = $this->cache_dir . $this->get_group_dir($group) . "/" . md5($id . DB_PASSWORD) . '.php'; 109 112 if (!file_exists($cache_file)) { 110 113 $this->cache_misses += 1; 111 114 return false; 112 115 } 113 $this->cache[$group][$id] = unserialize( @ file_get_contents($cache_file));116 $this->cache[$group][$id] = unserialize(substr(@ file_get_contents($cache_file), strlen(CACHE_SERIAL_HEADER), -strlen(CACHE_SERIAL_FOOTER))); 114 117 if ( false === $this->cache[$group][$id]) 115 118 $this->cache[$group][$id] = ''; … … 238 241 // TODO: If the id is no longer in the cache, it was deleted and 239 242 // the file should be removed. 240 $cache_file = $group_dir . md5($id . DB_PASSWORD) ;243 $cache_file = $group_dir . md5($id . DB_PASSWORD) . '.php'; 241 244 $temp_file = tempnam($group_dir, 'tmp'); 242 $serial = serialize($this->cache[$group][$id]);245 $serial = CACHE_SERIAL_HEADER . serialize($this->cache[$group][$id]) . CACHE_SERIAL_FOOTER; 243 246 $fd = fopen($temp_file, 'w'); 244 247 fputs($fd, $serial); 245 fclose($fd); 246 rename($temp_file, $cache_file); 248 fclose($fd); 249 if (!@rename($temp_file, $cache_file)) { 250 if (copy ($temp_file, $cache_file)) { 251 unlink($temp_file); 252 } 253 } 247 254 } 248 255 }
Note: See TracChangeset
for help on using the changeset viewer.