Skip to content

Commit 9b49863

Browse files
committed
Merge remote-tracking branch 'origin/develop'
# Conflicts: # CHANGELOG.md # includes/object-cache.php # languages/redis-cache.pot # readme.txt # redis-cache.php
2 parents 3e97403 + 0cfdb6d commit 9b49863

File tree

7 files changed

+129
-71
lines changed

7 files changed

+129
-71
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 2.5.4
4+
5+
- Respect `WP_REDIS_SCHEME` for Cluster connections
6+
- Fixed issue with Predis and `SentinelReplication` connection
7+
- Fixed double-slash in `admin.css` URL
8+
39
## 2.5.3
410

511
- Added `WP_REDIS_DISABLE_GROUP_FLUSH` constant

includes/class-plugin.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,12 @@ public function enqueue_admin_styles() {
333333
return;
334334
}
335335

336-
wp_enqueue_style( 'redis-cache', WP_REDIS_PLUGIN_DIR . '/assets/css/admin.css', [], WP_REDIS_VERSION );
336+
wp_enqueue_style(
337+
'redis-cache',
338+
trailingslashit( WP_REDIS_PLUGIN_DIR ) . 'assets/css/admin.css',
339+
[],
340+
WP_REDIS_VERSION
341+
);
337342
}
338343

339344
/**

includes/class-predis.php

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,30 @@ protected function build_cluster_connection_array() {
206206
$cluster = array_values( WP_REDIS_CLUSTER );
207207

208208
foreach ( $cluster as $key => $server ) {
209-
$connection_string = parse_url( $server );
209+
$components = parse_url( $server );
210+
211+
if ( ! empty( $components['scheme'] ) ) {
212+
$scheme = $components['scheme'];
213+
} elseif ( defined( 'WP_REDIS_SCHEME' ) ) {
214+
$scheme = WP_REDIS_SCHEME;
215+
} else {
216+
$scheme = null;
217+
}
210218

211-
$cluster[ $key ] = sprintf(
212-
"%s:%s",
213-
$connection_string['host'],
214-
$connection_string['port']
215-
);
219+
if ( isset( $scheme ) ) {
220+
$cluster[ $key ] = sprintf(
221+
'%s://%s:%d',
222+
$scheme,
223+
$components['host'],
224+
$components['port']
225+
);
226+
} else {
227+
$cluster[ $key ] = sprintf(
228+
'%s:%d',
229+
$components['host'],
230+
$components['port']
231+
);
232+
}
216233
}
217234

218235
return $cluster;

includes/object-cache.php

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Redis Object Cache Drop-In
44
* Plugin URI: https://wordpress.org/plugins/redis-cache/
55
* Description: A persistent object cache backend powered by Redis. Supports Predis, PhpRedis, Relay, replication, sentinels, clustering and WP-CLI.
6-
* Version: 2.5.3
6+
* Version: 2.5.4
77
* Author: Till Krüss
88
* Author URI: https://objectcache.pro
99
* License: GPLv3
@@ -1150,6 +1150,13 @@ public function fetch_info() {
11501150
} else if ($this->is_predis() && $this->redis->getConnection() instanceof Predis\Connection\Replication\MasterSlaveReplication) {
11511151
$info = $this->redis->getClientBy( 'role' , 'master' )->info();
11521152
} else {
1153+
if ( $this->is_predis() ) {
1154+
$connection = $this->redis->getConnection();
1155+
if ( $connection instanceof Predis\Connection\Replication\ReplicationInterface ) {
1156+
$connection->switchToMaster();
1157+
}
1158+
}
1159+
11531160
$info = $this->redis->info();
11541161
}
11551162

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

30293036
foreach ( $cluster as $key => $server ) {
3030-
$connection_string = parse_url( $server );
3037+
$components = parse_url( $server );
30313038

3032-
$cluster[ $key ] = sprintf(
3033-
"%s:%s",
3034-
$connection_string['host'],
3035-
$connection_string['port']
3036-
);
3039+
if ( ! empty( $components['scheme'] ) ) {
3040+
$scheme = $components['scheme'];
3041+
} elseif ( defined( 'WP_REDIS_SCHEME' ) ) {
3042+
$scheme = WP_REDIS_SCHEME;
3043+
} else {
3044+
$scheme = null;
3045+
}
3046+
3047+
if ( isset( $scheme ) ) {
3048+
$cluster[ $key ] = sprintf(
3049+
'%s://%s:%d',
3050+
$scheme,
3051+
$components['host'],
3052+
$components['port']
3053+
);
3054+
} else {
3055+
$cluster[ $key ] = sprintf(
3056+
'%s:%d',
3057+
$components['host'],
3058+
$components['port']
3059+
);
3060+
}
30373061
}
30383062

30393063
return $cluster;

0 commit comments

Comments
 (0)