Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect via unix socket instead of filesystem to be compatible with php open_basedir restrictions. #426

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) ###
Expand Down
3 changes: 2 additions & 1 deletion behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,9 @@
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"autoload": {
"psr-4": { "behat\\features\\bootstrap\\": "tests/behat/features/bootstrap/" }
}

}
5 changes: 4 additions & 1 deletion object-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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) =
Expand Down
35 changes: 35 additions & 0 deletions tests/behat/features/bootstrap/WpRedisFeatureContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
// features/bootstrap/WPRedisFeatureContext.php

namespace behat\features\bootstrap;

use Behat\Behat\Context\Context;

class WpRedisFeatureContext implements Context
{

/**
* Initializes context.
*
* Every scenario gets its own context instance.
* You can also pass arbitrary arguments to the
* context constructor through behat.yml.
*/
public function __construct()
{
}

/**
* Waits a certain number of seconds.
*
* @param int $seconds
* How long to wait.
*
* @When I wait :seconds second(s)
*/
public function wait($seconds)
{
sleep($seconds);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Feature: Load WordPress
When I go to "/wp-admin/options-general.php"
And I fill in "blogname" with "Pantheon WordPress Site"
And I press "submit"
When I wait "1" second
Then print current URL
And I should see "Settings saved."

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@ Feature: WP Redis
Then I should see "Redis Calls:"
And I should see "Cache Hits:"
And I should see "Cache Misses:"
And I should see "- get:"
And I should see "Redis Calls:"

# We call the same page twice to give Redis an opportunity to cache
# something so that `get` actually fires.
When I am on "/?redis_debug"
Then I should see "Group:"
Then I should see "- get"