diff --git a/wp-includes/cache.php b/wp-includes/cache.php index 197988b93..dede02787 100644 --- a/wp-includes/cache.php +++ b/wp-includes/cache.php @@ -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. @@ -174,14 +175,10 @@ class WP_Object_Cache { } function hash($data) { - global $wp_server_secret; - if ( empty($wp_server_secret) ) - $wp_server_secret = DB_PASSWORD; - if ( function_exists('hash_hmac') ) { - return hash_hmac('md5', $data, $wp_server_secret); + return hash_hmac('md5', $data, $this->secret); } else { - return md5($data . $wp_server_secret); + return md5($data . $this->secret); } } @@ -397,7 +394,7 @@ class WP_Object_Cache { } function WP_Object_Cache() { - global $blog_id; + global $blog_id, $wpdb; if (defined('DISABLE_CACHE')) return; @@ -426,6 +423,11 @@ class WP_Object_Cache { if (defined('CACHE_EXPIRATION_TIME')) $this->expiration_time = CACHE_EXPIRATION_TIME; + 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); } } diff --git a/wp-includes/pluggable-functions.php b/wp-includes/pluggable-functions.php index 43e0a8a1a..d8498f8d6 100644 --- a/wp-includes/pluggable-functions.php +++ b/wp-includes/pluggable-functions.php @@ -508,16 +508,24 @@ function wp_create_nonce($action = -1) { } endif; +if ( !function_exists('wp_salt') ) : +function wp_salt() { + $salt = get_option('secret'); + if ( empty($salt) ) + $salt = DB_PASSWORD . DB_USER . DB_NAME . DB_HOST . ABSPATH; + + return $salt; +} +endif; + if ( !function_exists('wp_hash') ) : function wp_hash($data) { - $secret = get_option('secret'); - if ( empty($secret) ) - $secret = DB_PASSWORD; + $salt = wp_salt(); if ( function_exists('hash_hmac') ) { - return hash_hmac('md5', $data, $secret); + return hash_hmac('md5', $data, $salt); } else { - return md5($data . $secret); + return md5($data . $salt); } } endif;