Skip to content

Commit

Permalink
Do the scheme as part of build_cluster_connection_array
Browse files Browse the repository at this point in the history
  • Loading branch information
yatsukhnenko committed Sep 9, 2024
1 parent a8cf650 commit 739fbb7
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions includes/class-predis.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,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

0 comments on commit 739fbb7

Please sign in to comment.