Skip to content

Commit

Permalink
Connect via unix socket instead of filesystem to be compatible with p…
Browse files Browse the repository at this point in the history
…hp open_basedir restrictions.

copied from #425
  • Loading branch information
jazzsequence authored May 30, 2023
1 parent 402461b commit 1a92dab
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions object-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
}
Expand Down

0 comments on commit 1a92dab

Please sign in to comment.