From a884f665817cb29e7cb7d40a95c88a57680bcc80 Mon Sep 17 00:00:00 2001 From: Tim Nolte Date: Fri, 24 Jun 2022 15:35:16 -0400 Subject: [PATCH] Fixes assumption that CACHE_PORT & CACHE_PASSWORD are Set. * Falls back on port 6379 if the CACHE_PORT is not configured. * Doesn't require a CACHE_PASSWORD to be set when it isn't used, or can't be. --- object-cache.php | 4 ++-- wp-redis.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/object-cache.php b/object-cache.php index 4f04b77..c20156f 100644 --- a/object-cache.php +++ b/object-cache.php @@ -1167,8 +1167,8 @@ public function build_client_parameters( $redis_server ) { if ( isset( $_SERVER['CACHE_HOST'] ) ) { $redis_server = array( 'host' => $_SERVER['CACHE_HOST'], - 'port' => $_SERVER['CACHE_PORT'], - 'auth' => $_SERVER['CACHE_PASSWORD'], + 'port' => ! empty( $_SERVER['CACHE_PORT'] ) ? $_SERVER['CACHE_PORT'] : 6379, + 'auth' => ! empty( $_SERVER['CACHE_PASSWORD'] ) ? $_SERVER['CACHE_PASSWORD'], null, 'database' => isset( $_SERVER['CACHE_DB'] ) ? $_SERVER['CACHE_DB'] : 0, ); } else { diff --git a/wp-redis.php b/wp-redis.php index 5da9639..07af5e1 100644 --- a/wp-redis.php +++ b/wp-redis.php @@ -39,8 +39,8 @@ function wp_redis_get_info() { if ( isset( $_SERVER['CACHE_HOST'] ) ) { $redis_server = array( 'host' => $_SERVER['CACHE_HOST'], - 'port' => $_SERVER['CACHE_PORT'], - 'auth' => $_SERVER['CACHE_PASSWORD'], + 'port' => ! empty( $_SERVER['CACHE_PORT'] ) ? $_SERVER['CACHE_PORT'] : 6379, + 'auth' => ! empty( $_SERVER['CACHE_PASSWORD'] ) ? $_SERVER['CACHE_PASSWORD'], null, 'database' => isset( $_SERVER['CACHE_DB'] ) ? $_SERVER['CACHE_DB'] : 0, ); } else {