Skip to content

Commit ede1390

Browse files
Merge pull request #333 from pantheon-systems/fix-global-group-ignore-logic
Fix logic associated with `WP_REDIS_IGNORE_GLOBAL_GROUPS`
2 parents cfed7ac + 7b45878 commit ede1390

File tree

6 files changed

+21
-6
lines changed

6 files changed

+21
-6
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
**Tags:** cache, plugin, redis
44
**Requires at least:** 3.0.1
55
**Tested up to:** 5.8
6-
**Stable tag:** 1.1.3
6+
**Stable tag:** 1.1.4
77
**License:** GPLv2 or later
88
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html
99

@@ -116,6 +116,9 @@ There's a known issue with WordPress `alloptions` cache design. Specifically, a
116116

117117
## Changelog ##
118118

119+
### 1.1.4 (October 21, 2021) ###
120+
* Fixes some faulty logic in `WP_REDIS_IGNORE_GLOBAL_GROUPS` check [[#333](https://github.com/pantheon-systems/wp-redis/pull/333)].
121+
119122
### 1.1.3 (October 21, 2021) ###
120123
* 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)].
121124

object-cache.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,11 @@ public function add( $key, $data, $group = 'default', $expire = WP_REDIS_DEFAULT
434434
public function add_global_groups( $groups ) {
435435
$groups = (array) $groups;
436436

437-
// Filter global groups
437+
// Allow force ignoring of global groups.
438438
if ( is_array( WP_REDIS_IGNORE_GLOBAL_GROUPS ) ) {
439-
$groups = array_diff_key( $groups, WP_REDIS_IGNORE_GLOBAL_GROUPS );
439+
$groups = array_diff( $groups, WP_REDIS_IGNORE_GLOBAL_GROUPS );
440440
}
441-
441+
442442
$groups = array_fill_keys( $groups, true );
443443
$this->global_groups = array_merge( $this->global_groups, $groups );
444444
}

readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: getpantheon, danielbachhuber, mboynes, Outlandish Josh
33
Tags: cache, plugin, redis
44
Requires at least: 3.0.1
55
Tested up to: 5.8
6-
Stable tag: 1.1.3
6+
Stable tag: 1.1.4
77
License: GPLv2 or later
88
License URI: http://www.gnu.org/licenses/gpl-2.0.html
99

@@ -116,6 +116,9 @@ There's a known issue with WordPress `alloptions` cache design. Specifically, a
116116

117117
== Changelog ==
118118

119+
= 1.1.4 (October 21, 2021) =
120+
* Fixes some faulty logic in `WP_REDIS_IGNORE_GLOBAL_GROUPS` check [[#333](https://github.com/pantheon-systems/wp-redis/pull/333)].
121+
119122
= 1.1.3 (October 21, 2021) =
120123
* 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)].
121124

tests/phpunit/bootstrap.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
define( 'WP_REDIS_USE_CACHE_GROUPS', true );
2222
}
2323

24+
define( 'WP_REDIS_IGNORE_GLOBAL_GROUPS', array( 'wp-redis-ignored-group' ) );
25+
2426
// Easiest way to get this to where WordPress will load it
2527
copy( dirname( dirname( dirname( __FILE__ ) ) ) . '/object-cache.php', $_core_dir . '/wp-content/object-cache.php' );
2628

tests/phpunit/test-cache.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,13 @@ public function test_wp_cache_replace() {
13771377
$this->assertFalse( wp_cache_get( $fake_key ) );
13781378
}
13791379

1380+
public function test_ignore_global_groups() {
1381+
$this->cache->add_global_groups( array( 'wp-redis-respected-group' ) );
1382+
$this->assertTrue( isset( $this->cache->global_groups['wp-redis-respected-group'] ) );
1383+
$this->cache->add_global_groups( array( 'wp-redis-ignored-group' ) );
1384+
$this->assertFalse( isset( $this->cache->global_groups['wp-redis-ignored-group'] ) );
1385+
}
1386+
13801387
public function test_wp_redis_get_info() {
13811388
if ( ! class_exists( 'Redis' ) ) {
13821389
$this->markTestSkipped( 'PHPRedis extension not available.' );

wp-redis.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: WP Redis
44
* Plugin URI: http://github.com/pantheon-systems/wp-redis/
55
* Description: WordPress Object Cache using Redis. Requires the PhpRedis extension (https://github.com/phpredis/phpredis).
6-
* Version: 1.1.3
6+
* Version: 1.1.4
77
* Author: Pantheon, Josh Koenig, Matthew Boynes, Daniel Bachhuber, Alley Interactive
88
* Author URI: https://pantheon.io/
99
*/

0 commit comments

Comments
 (0)