From 61368e356bfda9c50115b1fe98fb7550b9613a96 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Sat, 30 Jul 2016 06:17:40 +0100 Subject: [PATCH 1/4] Change WP_APC_KEY_SALT to WP_CACHE_KEY_SALT which is supported by other plugins. --- README.md | 2 +- object-cache.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 02bc3a6..41924d4 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Maybe, but I'm not going to support them, and you shouldn't still be running the ### I share `wp-config.php` among multiple WordPress installs. How can I guarantee key uniqueness? ### -Define `WP_APC_KEY_SALT` to something that is unique for each install (like an md5 of the MySQL host, database, and table prefix). +Define `WP_CACHE_KEY_SALT` to something that is unique for each install (like an md5 of the MySQL host, database, and table prefix). ## Changelog ## diff --git a/object-cache.php b/object-cache.php index 8707f22..3571cfc 100644 --- a/object-cache.php +++ b/object-cache.php @@ -359,12 +359,12 @@ private function __clone() { private function __construct() { global $blog_id; - if ( !defined( 'WP_APC_KEY_SALT' ) ) { + if ( !defined( 'WP_CACHE_KEY_SALT' ) ) { /** * Set in config if you are using some sort of shared * config where ABSPATH is the same on all sites */ - define( 'WP_APC_KEY_SALT', 'wp' ); + define( 'WP_CACHE_KEY_SALT', 'wp' ); } $this->abspath = md5( ABSPATH ); @@ -791,7 +791,7 @@ private function _get_cache_version( $key ) { * @return string The key */ private function _get_cache_version_key( $type, $value ) { - return WP_APC_KEY_SALT . ':' . $this->abspath . ':' . $type . ':' . $value; + return WP_CACHE_KEY_SALT . ':' . $this->abspath . ':' . $type . ':' . $value; } @@ -969,7 +969,7 @@ private function _key( $key, $group ) { $group_version = $this->_get_group_cache_version( $group ); $site_version = $this->_get_site_cache_version( $prefix ); - return WP_APC_KEY_SALT . ':' . $this->abspath . ':' . $prefix . ':' . $group . ':' . $key . ':v' . $site_version . '.' . $group_version; + return WP_CACHE_KEY_SALT . ':' . $this->abspath . ':' . $prefix . ':' . $group . ':' . $key . ':v' . $site_version . '.' . $group_version; } From 44092c14575b2b5e833548944e682c42e2f1820b Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Sat, 30 Jul 2016 06:25:36 +0100 Subject: [PATCH 2/4] function was missing for me in a new wordpress install; check it's existance before trying to use. --- object-cache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/object-cache.php b/object-cache.php index 3571cfc..9846038 100644 --- a/object-cache.php +++ b/object-cache.php @@ -385,7 +385,7 @@ private function __construct() { * @return bool False if cache key and group already exist, true on success */ public function add( $key, $var, $group = 'default', $ttl = 0 ) { - if ( wp_suspend_cache_addition() ) { + if ( function_exists('wp_suspend_cache_addition') && wp_suspend_cache_addition() ) { return false; } From c74407eeef4c2fe96f49bf2747bf13a7746d7e9e Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Sat, 30 Jul 2016 06:30:13 +0100 Subject: [PATCH 3/4] add note for PHP7 users re APCu_bc --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 41924d4..c508421 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ version has been cherry picked over to this version. ## Installation ## -1. Verify that you have PHP 5.2.4+ and a compatible APC version installed. +1. Verify that you have PHP 5.2.4+ and a compatible APC version installed. PHP7 users will need to install the APCu_bc [11] extension 2. Copy `object-cache.php` to your WordPress content directory (`wp-content/` by default). 3. Done! @@ -72,4 +72,5 @@ Define `WP_CACHE_KEY_SALT` to something that is unique for each install (like an [7]: https://github.com/l3rady/WordPress-APC-Object-Cache/pull/1 [8]: https://github.com/l3rady/WordPress-APC-Object-Cache/pull/7 [9]: https://github.com/l3rady/WordPress-APC-Object-Cache/pull/9 -[10]: https://github.com/l3rady/WordPress-APC-Object-Cache/pull/10 \ No newline at end of file +[10]: https://github.com/l3rady/WordPress-APC-Object-Cache/pull/10 +[11]: https://pecl.php.net/package/apcu_bc From 08197058cb5af26a7500a80d1298c4262615198b Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Sat, 30 Jul 2016 06:31:38 +0100 Subject: [PATCH 4/4] fix link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c508421..8237bc5 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ version has been cherry picked over to this version. ## Installation ## -1. Verify that you have PHP 5.2.4+ and a compatible APC version installed. PHP7 users will need to install the APCu_bc [11] extension +1. Verify that you have PHP 5.2.4+ and a compatible APC version installed. PHP7 users will need to install the [APCu_bc][11] extension 2. Copy `object-cache.php` to your WordPress content directory (`wp-content/` by default). 3. Done!