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 Redis version determination for predis replication connection #522

Merged
merged 5 commits into from
Jun 10, 2024
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 5 additions & 11 deletions includes/object-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
Loading