diff --git a/.circleci/config.yml b/.circleci/config.yml index 8397ee6..16b4591 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -40,7 +40,7 @@ commands: - run: sudo apt-get install mariadb-client-10.6 install-redis-extras: steps: - - run: + - run: name: "Install Redis Extras" command: | yes '' | sudo pecl install redis || true diff --git a/README.md b/README.md index 820297a..737c6d4 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,7 @@ There's a known issue with WordPress `alloptions` cache design. Specifically, a ## Changelog ## ### 1.4.3-dev ### +* Bug fix: Connect via unix socket instead of filesystem to be compatible with php open_basedir restrictions [[426](https://github.com/pantheon-systems/wp-redis/pull/426)] (props @hj-collab) * Bug fix: Fixes assumption that CACHE_PORT & CACHE_PASSWORD are Set. [[428](https://github.com/pantheon-systems/wp-redis/pull/428)] (props @timnolte) ### 1.4.2 (May 15, 2023) ### diff --git a/behat.yml b/behat.yml index ff5ce58..12dad86 100644 --- a/behat.yml +++ b/behat.yml @@ -3,10 +3,11 @@ default: suites: default: paths: - - tests/behat + - tests/behat/ contexts: - Behat\MinkExtension\Context\MinkContext - PantheonSystems\PantheonWordPressUpstreamTests\Behat\AdminLogIn + - behat\features\bootstrap\WpRedisFeatureContext extensions: Behat\MinkExtension: # base_url set by ENV diff --git a/composer.json b/composer.json index 9bc37b1..a5f0929 100644 --- a/composer.json +++ b/composer.json @@ -28,5 +28,9 @@ "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true } + }, + "autoload": { + "psr-4": { "behat\\features\\bootstrap\\": "tests/behat/features/bootstrap/" } } + } diff --git a/object-cache.php b/object-cache.php index d2f3ced..144a525 100644 --- a/object-cache.php +++ b/object-cache.php @@ -1261,9 +1261,12 @@ 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. + $port = ! empty( $redis_server['port'] ) ? $redis_server['port'] : 6379; } $defaults = [ diff --git a/readme.txt b/readme.txt index 2779580..f2515fe 100644 --- a/readme.txt +++ b/readme.txt @@ -103,6 +103,7 @@ There's a known issue with WordPress `alloptions` cache design. Specifically, a == Changelog == = 1.4.3-dev = +* Bug fix: Connect via unix socket instead of filesystem to be compatible with php open_basedir restrictions [[426](https://github.com/pantheon-systems/wp-redis/pull/426)] (props @hj-collab) * Bug fix: Fixes assumption that CACHE_PORT & CACHE_PASSWORD are Set. [[428](https://github.com/pantheon-systems/wp-redis/pull/428)] (props @tnolte) = 1.4.2 (May 15, 2023) = diff --git a/tests/behat/features/bootstrap/WpRedisFeatureContext.php b/tests/behat/features/bootstrap/WpRedisFeatureContext.php new file mode 100644 index 0000000..e5f0981 --- /dev/null +++ b/tests/behat/features/bootstrap/WpRedisFeatureContext.php @@ -0,0 +1,35 @@ +