diff --git a/CHANGELOG.md b/CHANGELOG.md index 3804d85c..efb65633 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- Fixed issues with Predis and replication connections +- Fixed several issues with Predis and cluster/replicated connection - Fixed rare fatal error in `show_error_and_die()` (one more time) ## 2.5.2 diff --git a/includes/class-predis.php b/includes/class-predis.php index 8f2f55f3..e3ccbb06 100644 --- a/includes/class-predis.php +++ b/includes/class-predis.php @@ -139,11 +139,10 @@ public function connect( $read_timeout = null ) { * @return bool */ public function flush( $throw_exception = false ) { - $flush_timeout = defined( 'WP_REDIS_FLUSH_TIMEOUT' ) - ? intval( WP_REDIS_FLUSH_TIMEOUT ) - : 5; - if ( is_null( $this->redis ) ) { + $flush_timeout = defined( 'WP_REDIS_FLUSH_TIMEOUT' ) + ? intval( WP_REDIS_FLUSH_TIMEOUT ) + : 5; try { $this->connect( $flush_timeout ); } catch ( Exception $exception ) { @@ -153,16 +152,16 @@ public function flush( $throw_exception = false ) { return false; } - } - if ( is_null( $this->redis ) ) { - return false; + if ( is_null( $this->redis ) ) { + return false; + } } if ( defined( 'WP_REDIS_CLUSTER' ) ) { try { - foreach ( $this->redis->_masters() as $master ) { - $this->redis->flushdb( $master ); + foreach ( $this->redis->getIterator() as $master ) { + $master->flushdb(); } } catch ( Exception $exception ) { if ( $throw_exception ) {