diff --git a/object-cache.php b/object-cache.php index dd2ff80..eb43cea 100644 --- a/object-cache.php +++ b/object-cache.php @@ -12,8 +12,15 @@ // Users with setups where multiple installs share a common wp-config.php or $table_prefix // can use this to guarantee uniqueness for the keys generated by this object cache +// If WP_CACHE_KEY_SALT is not set, generate a key from DB parameters and blog id if ( ! defined( 'WP_CACHE_KEY_SALT' ) ) { - define( 'WP_CACHE_KEY_SALT', '' ); + if ( defined('DB_NAME') && defined('DB_USER') && defined('DB_PASSWORD') && defined('DB_HOST')) { + global $blog_id, $table_prefix; + define( 'WP_CACHE_KEY_SALT', md5( DB_NAME . ":" . DB_USER . ":" . DB_PASSWORD . ":" . DB_HOST . ":" . $table_prefix . ":" . $blog_id ) ); + } + else { + define( 'WP_CACHE_KEY_SALT', '' ); + } } function wp_cache_add( $key, $data, $group = '', $expire = 0 ) {