Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	includes/object-cache.php
#	languages/redis-cache.pot
#	readme.txt
#	redis-cache.php
  • Loading branch information
tillkruss committed Oct 15, 2024
2 parents 3e97403 + 0cfdb6d commit 9b49863
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 71 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 2.5.4

- Respect `WP_REDIS_SCHEME` for Cluster connections
- Fixed issue with Predis and `SentinelReplication` connection
- Fixed double-slash in `admin.css` URL

## 2.5.3

- Added `WP_REDIS_DISABLE_GROUP_FLUSH` constant
Expand Down
7 changes: 6 additions & 1 deletion includes/class-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,12 @@ public function enqueue_admin_styles() {
return;
}

wp_enqueue_style( 'redis-cache', WP_REDIS_PLUGIN_DIR . '/assets/css/admin.css', [], WP_REDIS_VERSION );
wp_enqueue_style(
'redis-cache',
trailingslashit( WP_REDIS_PLUGIN_DIR ) . 'assets/css/admin.css',
[],
WP_REDIS_VERSION
);
}

/**
Expand Down
29 changes: 23 additions & 6 deletions includes/class-predis.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,30 @@ protected function build_cluster_connection_array() {
$cluster = array_values( WP_REDIS_CLUSTER );

foreach ( $cluster as $key => $server ) {
$connection_string = parse_url( $server );
$components = parse_url( $server );

if ( ! empty( $components['scheme'] ) ) {
$scheme = $components['scheme'];
} elseif ( defined( 'WP_REDIS_SCHEME' ) ) {
$scheme = WP_REDIS_SCHEME;
} else {
$scheme = null;
}

$cluster[ $key ] = sprintf(
"%s:%s",
$connection_string['host'],
$connection_string['port']
);
if ( isset( $scheme ) ) {
$cluster[ $key ] = sprintf(
'%s://%s:%d',
$scheme,
$components['host'],
$components['port']
);
} else {
$cluster[ $key ] = sprintf(
'%s:%d',
$components['host'],
$components['port']
);
}
}

return $cluster;
Expand Down
38 changes: 31 additions & 7 deletions includes/object-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Redis Object Cache Drop-In
* Plugin URI: https://wordpress.org/plugins/redis-cache/
* Description: A persistent object cache backend powered by Redis. Supports Predis, PhpRedis, Relay, replication, sentinels, clustering and WP-CLI.
* Version: 2.5.3
* Version: 2.5.4
* Author: Till Krüss
* Author URI: https://objectcache.pro
* License: GPLv3
Expand Down Expand Up @@ -1150,6 +1150,13 @@ public function fetch_info() {
} else if ($this->is_predis() && $this->redis->getConnection() instanceof Predis\Connection\Replication\MasterSlaveReplication) {
$info = $this->redis->getClientBy( 'role' , 'master' )->info();
} else {
if ( $this->is_predis() ) {
$connection = $this->redis->getConnection();
if ( $connection instanceof Predis\Connection\Replication\ReplicationInterface ) {
$connection->switchToMaster();
}
}

$info = $this->redis->info();
}

Expand Down Expand Up @@ -3027,13 +3034,30 @@ protected function build_cluster_connection_array() {
$cluster = array_values( WP_REDIS_CLUSTER );

foreach ( $cluster as $key => $server ) {
$connection_string = parse_url( $server );
$components = parse_url( $server );

$cluster[ $key ] = sprintf(
"%s:%s",
$connection_string['host'],
$connection_string['port']
);
if ( ! empty( $components['scheme'] ) ) {
$scheme = $components['scheme'];
} elseif ( defined( 'WP_REDIS_SCHEME' ) ) {
$scheme = WP_REDIS_SCHEME;
} else {
$scheme = null;
}

if ( isset( $scheme ) ) {
$cluster[ $key ] = sprintf(
'%s://%s:%d',
$scheme,
$components['host'],
$components['port']
);
} else {
$cluster[ $key ] = sprintf(
'%s:%d',
$components['host'],
$components['port']
);
}
}

return $cluster;
Expand Down
Loading

0 comments on commit 9b49863

Please sign in to comment.