Skip to content

Commit 5f9ab1a

Browse files
committed
Fetch Redis server info for replicated connections
1 parent 2900a52 commit 5f9ab1a

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

includes/object-cache.php

+4-10
Original file line numberDiff line numberDiff line change
@@ -1139,24 +1139,18 @@ protected function connect_using_hhvm( $parameters ) {
11391139
* @return void
11401140
*/
11411141
public function fetch_info() {
1142-
$options = method_exists( $this->redis, 'getOptions' )
1143-
? $this->redis->getOptions()
1144-
: new stdClass();
1145-
1146-
if ( isset( $options->replication ) && $options->replication ) {
1147-
return;
1148-
}
1149-
11501142
if ( defined( 'WP_REDIS_CLUSTER' ) ) {
11511143
$connectionId = is_string( WP_REDIS_CLUSTER )
11521144
? 'SERVER'
11531145
: current( $this->build_cluster_connection_array() );
11541146

1155-
$info = $this->determine_client() === 'predis'
1147+
$info = $this->is_predis()
11561148
? $this->redis->getClientBy( 'id', $connectionId )->info()
11571149
: $this->redis->info( $connectionId );
11581150
} else {
1159-
$info = $this->redis->info();
1151+
$info = $this->is_predis() && $this->redis->getConnection() instanceof Predis\Connection\Replication\MasterSlaveReplication
1152+
? $this->redis->getClientBy( 'role' , 'master' )->info()
1153+
: $this->redis->info();
11601154
}
11611155

11621156
if ( isset( $info['redis_version'] ) ) {

0 commit comments

Comments
 (0)