Redis Object Cache - Version 1.4.3

Version Description

  • Require PHP 5.4 or newer
    • Use pretty print in diagnostics
    • Throw exception if Redis library is missing
    • Fixed cache not flushing for some users
    • Fixed admin issues when WP_REDIS_DISABLED is false
Download this release

Release Info

Developer tillkruess
Plugin Icon 128x128 Redis Object Cache
Version 1.4.3
Comparing to
See all releases

Code changes from version 1.4.2 to 1.4.3

includes/diagnostics.php CHANGED
@@ -1,9 +1,11 @@
1
  <?php
2
 
 
 
3
  global $wp_object_cache;
4
 
5
  $info = $plugins = $dropins = array();
6
- $dropin = $this->validate_object_cache_dropin();
7
 
8
  $info[ 'Status' ] = $this->get_status();
9
  $info[ 'Client' ] = $this->get_redis_client_name();
@@ -67,8 +69,8 @@ if ( defined( 'WP_REDIS_PASSWORD' ) ) {
67
  }
68
 
69
  if ( $dropin ) {
70
- $info[ 'Global Groups' ] = json_encode( $wp_object_cache->global_groups );
71
- $info[ 'Ignored Groups' ] = json_encode( $wp_object_cache->ignored_groups );
72
  }
73
 
74
  foreach ( $info as $name => $value ) {
1
  <?php
2
 
3
+ // TODO: detect constants being defined too late...
4
+
5
  global $wp_object_cache;
6
 
7
  $info = $plugins = $dropins = array();
8
+ $dropin = $this->validate_object_cache_dropin() && ( ! defined('WP_REDIS_DISABLED') || ! WP_REDIS_DISABLED );
9
 
10
  $info[ 'Status' ] = $this->get_status();
11
  $info[ 'Client' ] = $this->get_redis_client_name();
69
  }
70
 
71
  if ( $dropin ) {
72
+ $info[ 'Global Groups' ] = json_encode( $wp_object_cache->global_groups, JSON_PRETTY_PRINT );
73
+ $info[ 'Ignored Groups' ] = json_encode( $wp_object_cache->ignored_groups, JSON_PRETTY_PRINT );
74
  }
75
 
76
  foreach ( $info as $name => $value ) {
includes/object-cache.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Redis Object Cache Drop-In
4
  Plugin URI: http://wordpress.org/plugins/redis-cache/
5
  Description: A persistent object cache backend powered by Redis. Supports Predis, PhpRedis, HHVM, replication, clustering and WP-CLI.
6
- Version: 1.4.2
7
  Author: Till Krüss
8
  Author URI: https://till.im/
9
  License: GPLv3
@@ -186,9 +186,6 @@ function wp_cache_init()
186
  }
187
  }
188
 
189
- // wp_cache_switch_to_blog
190
- // wp_cache_switch_to_blog( get_current_blog_id() );
191
-
192
  /**
193
  * Replaces a value in cache.
194
  *
@@ -472,8 +469,16 @@ class WP_Object_Cache
472
 
473
  // Load bundled Predis library
474
  if (! class_exists('Predis\Client')) {
475
- $plugin_dir = defined('WP_PLUGIN_DIR') ? WP_PLUGIN_DIR : WP_CONTENT_DIR . '/plugins';
476
- require_once $plugin_dir . '/redis-cache/includes/predis/autoload.php';
 
 
 
 
 
 
 
 
477
  }
478
 
479
  $options = array();
@@ -1073,7 +1078,7 @@ class WP_Object_Cache
1073
  $salt = defined('WP_CACHE_KEY_SALT') ? trim(WP_CACHE_KEY_SALT) : '';
1074
  $prefix = in_array($group, $this->global_groups) ? $this->global_prefix : $this->blog_prefix;
1075
 
1076
- return "{{$salt}{$prefix}}:{$group}:{$key}";
1077
  }
1078
 
1079
  /**
3
  Plugin Name: Redis Object Cache Drop-In
4
  Plugin URI: http://wordpress.org/plugins/redis-cache/
5
  Description: A persistent object cache backend powered by Redis. Supports Predis, PhpRedis, HHVM, replication, clustering and WP-CLI.
6
+ Version: 1.4.3
7
  Author: Till Krüss
8
  Author URI: https://till.im/
9
  License: GPLv3
186
  }
187
  }
188
 
 
 
 
189
  /**
190
  * Replaces a value in cache.
191
  *
469
 
470
  // Load bundled Predis library
471
  if (! class_exists('Predis\Client')) {
472
+ $predis = sprintf(
473
+ '%s/redis-cache/includes/predis/autoload.php',
474
+ defined('WP_PLUGIN_DIR') ? WP_PLUGIN_DIR : WP_CONTENT_DIR . '/plugins'
475
+ );
476
+
477
+ if (file_exists($predis)) {
478
+ require_once $predis;
479
+ } else {
480
+ throw new Exception('Predis library not found. Re-install Redis Cache plugin or delete object-cache.php.');
481
+ }
482
  }
483
 
484
  $options = array();
1078
  $salt = defined('WP_CACHE_KEY_SALT') ? trim(WP_CACHE_KEY_SALT) : '';
1079
  $prefix = in_array($group, $this->global_groups) ? $this->global_prefix : $this->blog_prefix;
1080
 
1081
+ return "{$salt}{$prefix}:{$group}:{$key}";
1082
  }
1083
 
1084
  /**
readme.txt CHANGED
@@ -4,7 +4,8 @@ Donate link: https://www.paypal.me/tillkruss
4
  Tags: redis, predis, phpredis, hhvm, pecl, caching, cache, object cache, performance, replication, clustering
5
  Requires at least: 3.3
6
  Tested up to: 5.2
7
- Stable tag: 1.4.2
 
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -179,6 +180,14 @@ The following commands are supported:
179
 
180
  == Changelog ==
181
 
 
 
 
 
 
 
 
 
182
  = 1.4.2 =
183
 
184
  * Added graceful Redis failures and `WP_REDIS_GRACEFUL` constant
4
  Tags: redis, predis, phpredis, hhvm, pecl, caching, cache, object cache, performance, replication, clustering
5
  Requires at least: 3.3
6
  Tested up to: 5.2
7
+ Requires PHP: 5.4
8
+ Stable tag: 1.4.3
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
 
180
 
181
  == Changelog ==
182
 
183
+ = 1.4.3 =
184
+
185
+ * Require PHP 5.4 or newer
186
+ * Use pretty print in diagnostics
187
+ * Throw exception if Redis library is missing
188
+ * Fixed cache not flushing for some users
189
+ * Fixed admin issues when `WP_REDIS_DISABLED` is `false`
190
+
191
  = 1.4.2 =
192
 
193
  * Added graceful Redis failures and `WP_REDIS_GRACEFUL` constant
redis-cache.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Redis Object Cache
4
  Plugin URI: https://wordpress.org/plugins/redis-cache/
5
  Description: A persistent object cache backend powered by Redis. Supports Predis, PhpRedis, HHVM, replication, clustering and WP-CLI.
6
- Version: 1.4.2
7
  Text Domain: redis-cache
8
  Domain Path: /languages
9
  Author: Till Krüss
@@ -145,7 +145,10 @@ class RedisObjectCache {
145
 
146
  public function get_status() {
147
 
148
- if ( ! $this->object_cache_dropin_exists() ) {
 
 
 
149
  return __( 'Disabled', 'redis-cache' );
150
  }
151
 
@@ -167,6 +170,10 @@ class RedisObjectCache {
167
 
168
  global $wp_object_cache;
169
 
 
 
 
 
170
  if ( $this->validate_object_cache_dropin() ) {
171
  return $wp_object_cache->redis_status();
172
  }
3
  Plugin Name: Redis Object Cache
4
  Plugin URI: https://wordpress.org/plugins/redis-cache/
5
  Description: A persistent object cache backend powered by Redis. Supports Predis, PhpRedis, HHVM, replication, clustering and WP-CLI.
6
+ Version: 1.4.3
7
  Text Domain: redis-cache
8
  Domain Path: /languages
9
  Author: Till Krüss
145
 
146
  public function get_status() {
147
 
148
+ if (
149
+ ! $this->object_cache_dropin_exists() ||
150
+ ( defined( 'WP_REDIS_DISABLED' ) && WP_REDIS_DISABLED )
151
+ ) {
152
  return __( 'Disabled', 'redis-cache' );
153
  }
154
 
170
 
171
  global $wp_object_cache;
172
 
173
+ if ( defined( 'WP_REDIS_DISABLED' ) && WP_REDIS_DISABLED ) {
174
+ return;
175
+ }
176
+
177
  if ( $this->validate_object_cache_dropin() ) {
178
  return $wp_object_cache->redis_status();
179
  }