From 1a92dab03e6b9ab9618bebca6c15f5e9efc26ba1 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Tue, 30 May 2023 08:43:31 -0600 Subject: [PATCH] Connect via unix socket instead of filesystem to be compatible with php open_basedir restrictions. copied from #425 --- object-cache.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/object-cache.php b/object-cache.php index 05c6526..d5f00d9 100644 --- a/object-cache.php +++ b/object-cache.php @@ -1256,7 +1256,7 @@ public function build_client_parameters( $redis_server ) { } } - if ( file_exists( $redis_server['host'] ) && 'socket' === filetype( $redis_server['host'] ) ) { // unix socket connection. + if ( strpos($redis_server['host'], 'unix:///') === 0 ) ) { // Unix socket connection. // port must be null or socket won't connect. $port = null; } else { // tcp connection. @@ -1470,9 +1470,9 @@ protected function _exception_handler( $exception ) { try { $this->last_triggered_error = 'WP Redis: ' . $exception->getMessage(); // Be friendly to developers debugging production servers by triggering an error. - + // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error,WordPress.Security.EscapeOutput.OutputNotEscaped - trigger_error( $this->last_triggered_error, E_USER_WARNING ); + trigger_error( $this->last_triggered_error, E_USER_WARNING ); } catch ( PHPUnit_Framework_Error_Warning $e ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch // PHPUnit throws an Exception when `trigger_error()` is called. To ensure our tests (which expect Exceptions to be caught) continue to run, we catch the PHPUnit exception and inspect the RedisException message. }