summaryrefslogtreecommitdiffstats
path: root/wp-includes/cache.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2008-01-15 11:56:58 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2008-01-15 11:56:58 +0000
commit8dcb4eb1ed5ce55ab32860892857de425b09f0d1 (patch)
tree63056bfb78fc8caccb511996d7c60671fbbb7155 /wp-includes/cache.php
parenteeaa9f9ac9cfb3d6bd2d4ce361c407f9c6acb698 (diff)
downloadwordpress-mu-8dcb4eb1ed5ce55ab32860892857de425b09f0d1.tar.gz
wordpress-mu-8dcb4eb1ed5ce55ab32860892857de425b09f0d1.tar.xz
wordpress-mu-8dcb4eb1ed5ce55ab32860892857de425b09f0d1.zip
Fix disk caching: save and gets match, avoid possible collisions between blogs
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1187 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/cache.php')
-rw-r--r--wp-includes/cache.php19
1 files changed, 11 insertions, 8 deletions
diff --git a/wp-includes/cache.php b/wp-includes/cache.php
index b877b81..1d481a6 100644
--- a/wp-includes/cache.php
+++ b/wp-includes/cache.php
@@ -139,11 +139,12 @@ class WP_Object_Cache {
}
function get($id, $group = 'default', $count_hits = true) {
- $hash = $this->key($id, $group);
- $group_key = $this->key( '', $group );
if (empty ($group))
$group = 'default';
+ $group_key = $this->key( '', $group );
+ $hash = $this->key($id, $group_key);
+
if (isset ($this->cache[$hash])) {
if ($count_hits)
$this->warm_cache_hits += 1;
@@ -168,7 +169,7 @@ class WP_Object_Cache {
return false;
}
- $cache_file = $this->cache_dir.$this->get_group_dir($group_key)."/".$this->hash($id).'.php';
+ $cache_file = $this->cache_dir.$this->get_group_dir($group_key)."/".$this->hash($hash).'.php';
if (!file_exists($cache_file)) {
$this->non_existant_objects[$hash] = true;
$this->cache_misses += 1;
@@ -285,7 +286,8 @@ class WP_Object_Cache {
}
function set($id, $data, $group = 'default', $expire = '') {
- $hash = $this->key($id, $group);
+ $group_key = $this->key( '', $group );
+ $hash = $this->key($id, $group_key);
if (empty ($group))
$group = 'default';
@@ -294,7 +296,7 @@ class WP_Object_Cache {
$this->cache[$hash] = $data;
unset ($this->non_existant_objects[$hash]);
- $this->dirty_objects[$this->key( '', $group )][] = $id;
+ $this->dirty_objects[$group_key][] = $id;
return true;
}
@@ -338,17 +340,18 @@ class WP_Object_Cache {
$ids = array_unique($ids);
foreach ($ids as $id) {
- $cache_file = $group_dir.$this->hash($group.'-'.$id).'.php';
+ $hash = $this->key($id, $group);
+ $cache_file = $group_dir.$this->hash($hash).'.php';
// Remove the cache file if the key is not set.
- if (!isset ($this->cache[$group.'-'.$id])) {
+ if (!isset ($this->cache[$hash])) {
if (file_exists($cache_file))
@ unlink($cache_file);
continue;
}
$temp_file = tempnam($group_dir, 'tmp');
- $serial = CACHE_SERIAL_HEADER.base64_encode(serialize($this->cache[$group.'-'.$id])).CACHE_SERIAL_FOOTER;
+ $serial = CACHE_SERIAL_HEADER.base64_encode(serialize($this->cache[$hash])).CACHE_SERIAL_FOOTER;
$fd = @fopen($temp_file, 'w');
if ( false === $fd ) {
$errors++;