Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logic associated with WP_REDIS_IGNORE_GLOBAL_GROUPS #333

Merged
merged 2 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)].

Expand Down
6 changes: 3 additions & 3 deletions object-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)].

Expand Down
2 changes: 2 additions & 0 deletions tests/phpunit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );

Expand Down
7 changes: 7 additions & 0 deletions tests/phpunit/test-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.' );
Expand Down
2 changes: 1 addition & 1 deletion wp-redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/
*/
Expand Down