summaryrefslogtreecommitdiffstats
path: root/wp-inst/wp-includes/cache.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-06-07 14:28:14 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-06-07 14:28:14 +0000
commit9d42ec4ee5db0437e9ad14b793f044fa0f5de8fe (patch)
treea0bb93e81f1856204377f936a97a8a285f77f2b7 /wp-inst/wp-includes/cache.php
parent16cdc878fce216364bd57f498baeeb1b94ca8662 (diff)
downloadwordpress-mu-9d42ec4ee5db0437e9ad14b793f044fa0f5de8fe.tar.gz
wordpress-mu-9d42ec4ee5db0437e9ad14b793f044fa0f5de8fe.tar.xz
wordpress-mu-9d42ec4ee5db0437e9ad14b793f044fa0f5de8fe.zip
WP Merge and new features
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@550 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-inst/wp-includes/cache.php')
-rw-r--r--wp-inst/wp-includes/cache.php28
1 files changed, 21 insertions, 7 deletions
diff --git a/wp-inst/wp-includes/cache.php b/wp-inst/wp-includes/cache.php
index 0ec19e1..976a0b3 100644
--- a/wp-inst/wp-includes/cache.php
+++ b/wp-inst/wp-includes/cache.php
@@ -47,8 +47,8 @@ function wp_cache_set($key, $data, $flag = '', $expire = 0) {
return $wp_object_cache->set($key, $data, $flag, $expire);
}
-define('CACHE_SERIAL_HEADER', "<?php\n//");
-define('CACHE_SERIAL_FOOTER', "\n?".">");
+define('CACHE_SERIAL_HEADER', "<?php\n/*");
+define('CACHE_SERIAL_FOOTER', "*/\n?".">");
class WP_Object_Cache {
var $cache_dir;
@@ -64,6 +64,7 @@ class WP_Object_Cache {
var $cold_cache_hits = 0;
var $warm_cache_hits = 0;
var $cache_misses = 0;
+ var $secret = '';
function acquire_lock() {
// Acquire a write lock.
@@ -142,7 +143,7 @@ class WP_Object_Cache {
return false;
}
- $cache_file = $this->cache_dir.$this->get_group_dir($group)."/".md5($id.DB_PASSWORD).'.php';
+ $cache_file = $this->cache_dir.$this->get_group_dir($group)."/".$this->hash($id).'.php';
if (!file_exists($cache_file)) {
$this->non_existant_objects[$group][$id] = true;
$this->cache_misses += 1;
@@ -158,7 +159,7 @@ class WP_Object_Cache {
return false;
}
- $this->cache[$group][$id] = unserialize(substr(@ file_get_contents($cache_file), strlen(CACHE_SERIAL_HEADER), -strlen(CACHE_SERIAL_FOOTER)));
+ $this->cache[$group][$id] = unserialize(base64_decode(substr(@ file_get_contents($cache_file), strlen(CACHE_SERIAL_HEADER), -strlen(CACHE_SERIAL_FOOTER))));
if (false === $this->cache[$group][$id])
$this->cache[$group][$id] = '';
@@ -173,6 +174,14 @@ class WP_Object_Cache {
return "{$this->blog_id}/$group";
}
+ function hash($data) {
+ if ( function_exists('hash_hmac') ) {
+ return hash_hmac('md5', $data, $this->secret);
+ } else {
+ return md5($data . $this->secret);
+ }
+ }
+
function load_group_from_db($group) {
global $wpdb;
@@ -322,7 +331,7 @@ class WP_Object_Cache {
$ids = array_unique($ids);
foreach ($ids as $id) {
- $cache_file = $group_dir.md5($id.DB_PASSWORD).'.php';
+ $cache_file = $group_dir.$this->hash($id).'.php';
// Remove the cache file if the key is not set.
if (!isset ($this->cache[$group][$id])) {
@@ -332,7 +341,7 @@ class WP_Object_Cache {
}
$temp_file = tempnam($group_dir, 'tmp');
- $serial = CACHE_SERIAL_HEADER.serialize($this->cache[$group][$id]).CACHE_SERIAL_FOOTER;
+ $serial = CACHE_SERIAL_HEADER.base64_encode(serialize($this->cache[$group][$id])).CACHE_SERIAL_FOOTER;
$fd = @fopen($temp_file, 'w');
if ( false === $fd ) {
$errors++;
@@ -414,7 +423,12 @@ class WP_Object_Cache {
if (defined('CACHE_EXPIRATION_TIME'))
$this->expiration_time = CACHE_EXPIRATION_TIME;
- $this->blog_id = md5($blog_id);
+ if ( defined('WP_SECRET') )
+ $this->secret = WP_SECRET;
+ else
+ $this->secret = DB_PASSWORD . DB_USER . DB_NAME . DB_HOST . ABSPATH;
+
+ $this->blog_id = $this->hash($blog_id);
}
}
?>