diff --git a/README.md b/README.md index cd17da9..d85a3c7 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ **Tags:** cache, plugin, redis **Requires at least:** 3.0.1 **Tested up to:** 5.8 -**Stable tag:** 1.1.3 +**Stable tag:** 1.1.4 **License:** GPLv2 or later **License URI:** http://www.gnu.org/licenses/gpl-2.0.html @@ -116,6 +116,9 @@ There's a known issue with WordPress `alloptions` cache design. Specifically, a ## Changelog ## +### 1.1.4 (October 21, 2021) ### +* Fixes some faulty logic in `WP_REDIS_IGNORE_GLOBAL_GROUPS` check [[#333](https://github.com/pantheon-systems/wp-redis/pull/333)]. + ### 1.1.3 (October 21, 2021) ### * Supports a `WP_REDIS_IGNORE_GLOBAL_GROUPS` constant to prevent groups from being added to global caching group [[#331](https://github.com/pantheon-systems/wp-redis/pull/331)]. diff --git a/object-cache.php b/object-cache.php index 6122418..641ed44 100644 --- a/object-cache.php +++ b/object-cache.php @@ -434,11 +434,11 @@ public function add( $key, $data, $group = 'default', $expire = WP_REDIS_DEFAULT public function add_global_groups( $groups ) { $groups = (array) $groups; - // Filter global groups + // Allow force ignoring of global groups. if ( is_array( WP_REDIS_IGNORE_GLOBAL_GROUPS ) ) { - $groups = array_diff_key( $groups, WP_REDIS_IGNORE_GLOBAL_GROUPS ); + $groups = array_diff( $groups, WP_REDIS_IGNORE_GLOBAL_GROUPS ); } - + $groups = array_fill_keys( $groups, true ); $this->global_groups = array_merge( $this->global_groups, $groups ); } diff --git a/readme.txt b/readme.txt index f89d469..782f22f 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: getpantheon, danielbachhuber, mboynes, Outlandish Josh Tags: cache, plugin, redis Requires at least: 3.0.1 Tested up to: 5.8 -Stable tag: 1.1.3 +Stable tag: 1.1.4 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -116,6 +116,9 @@ There's a known issue with WordPress `alloptions` cache design. Specifically, a == Changelog == += 1.1.4 (October 21, 2021) = +* Fixes some faulty logic in `WP_REDIS_IGNORE_GLOBAL_GROUPS` check [[#333](https://github.com/pantheon-systems/wp-redis/pull/333)]. + = 1.1.3 (October 21, 2021) = * Supports a `WP_REDIS_IGNORE_GLOBAL_GROUPS` constant to prevent groups from being added to global caching group [[#331](https://github.com/pantheon-systems/wp-redis/pull/331)]. diff --git a/tests/phpunit/bootstrap.php b/tests/phpunit/bootstrap.php index ead560b..ac7b0c8 100644 --- a/tests/phpunit/bootstrap.php +++ b/tests/phpunit/bootstrap.php @@ -21,6 +21,8 @@ define( 'WP_REDIS_USE_CACHE_GROUPS', true ); } +define( 'WP_REDIS_IGNORE_GLOBAL_GROUPS', array( 'wp-redis-ignored-group' ) ); + // Easiest way to get this to where WordPress will load it copy( dirname( dirname( dirname( __FILE__ ) ) ) . '/object-cache.php', $_core_dir . '/wp-content/object-cache.php' ); diff --git a/tests/phpunit/test-cache.php b/tests/phpunit/test-cache.php index 3cebac1..d7314ec 100644 --- a/tests/phpunit/test-cache.php +++ b/tests/phpunit/test-cache.php @@ -1377,6 +1377,13 @@ public function test_wp_cache_replace() { $this->assertFalse( wp_cache_get( $fake_key ) ); } + public function test_ignore_global_groups() { + $this->cache->add_global_groups( array( 'wp-redis-respected-group' ) ); + $this->assertTrue( isset( $this->cache->global_groups['wp-redis-respected-group'] ) ); + $this->cache->add_global_groups( array( 'wp-redis-ignored-group' ) ); + $this->assertFalse( isset( $this->cache->global_groups['wp-redis-ignored-group'] ) ); + } + public function test_wp_redis_get_info() { if ( ! class_exists( 'Redis' ) ) { $this->markTestSkipped( 'PHPRedis extension not available.' ); diff --git a/wp-redis.php b/wp-redis.php index 092861d..fbe7439 100644 --- a/wp-redis.php +++ b/wp-redis.php @@ -3,7 +3,7 @@ * Plugin Name: WP Redis * Plugin URI: http://github.com/pantheon-systems/wp-redis/ * Description: WordPress Object Cache using Redis. Requires the PhpRedis extension (https://github.com/phpredis/phpredis). - * Version: 1.1.3 + * Version: 1.1.4 * Author: Pantheon, Josh Koenig, Matthew Boynes, Daniel Bachhuber, Alley Interactive * Author URI: https://pantheon.io/ */