diff --git a/CHANGELOG.md b/CHANGELOG.md index 71128aff..3804d85c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- Fixed `wp_cache_flush_group` issue with Predis and replication connection +- Fixed issues with Predis and replication connections - Fixed rare fatal error in `show_error_and_die()` (one more time) ## 2.5.2 diff --git a/includes/object-cache.php b/includes/object-cache.php index 61b0c429..abac5c94 100644 --- a/includes/object-cache.php +++ b/includes/object-cache.php @@ -1139,22 +1139,16 @@ protected function connect_using_hhvm( $parameters ) { * @return void */ public function fetch_info() { - $options = method_exists( $this->redis, 'getOptions' ) - ? $this->redis->getOptions() - : new stdClass(); - - if ( isset( $options->replication ) && $options->replication ) { - return; - } - if ( defined( 'WP_REDIS_CLUSTER' ) ) { $connectionId = is_string( WP_REDIS_CLUSTER ) ? 'SERVER' : current( $this->build_cluster_connection_array() ); - $info = $this->determine_client() === 'predis' + $info = $this->is_predis() ? $this->redis->getClientBy( 'id', $connectionId )->info() : $this->redis->info( $connectionId ); + } else if ($this->is_predis() && $this->redis->getConnection() instanceof Predis\Connection\Replication\MasterSlaveReplication) { + $info = $this->redis->getClientBy( 'role' , 'master' )->info(); } else { $info = $this->redis->info(); } @@ -1888,7 +1882,7 @@ protected function lua_flush_closure( $salt, $escape = true ) { return i LUA; - if ( version_compare( $this->redis_version(), '5', '<' ) && version_compare( $this->redis_version(), '3.2', '>=' ) ) { + if ( isset($this->redis_version) && version_compare( $this->redis_version, '5', '<' ) && version_compare( $this->redis_version, '3.2', '>=' ) ) { $script = 'redis.replicate_commands()' . "\n" . $script; } @@ -1940,7 +1934,7 @@ function ( $group ) { until 0 == cur return i LUA; - if ( version_compare( $this->redis_version(), '5', '<' ) && version_compare( $this->redis_version(), '3.2', '>=' ) ) { + if ( isset($this->redis_version) && version_compare( $this->redis_version, '5', '<' ) && version_compare( $this->redis_version, '3.2', '>=' ) ) { $script = 'redis.replicate_commands()' . "\n" . $script; }