Skip to content

Commit

Permalink
Merge pull request #265 from pantheon-systems/fix-226-handle-redis-ex…
Browse files Browse the repository at this point in the history
…ception-on-connect

Catch exceptions when trying to connect to Redis
  • Loading branch information
danielbachhuber authored Jan 15, 2020
2 parents 103d6e0 + 2201173 commit dd58ff8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
**Tags:** cache, plugin, redis
**Requires at least:** 3.0.1
**Tested up to:** 5.3
**Stable tag:** 0.8.1
**Stable tag:** 0.8.2
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -107,6 +107,9 @@ There's a known issue with WordPress `alloptions` cache design. Specifically, a

## Changelog ##

### 0.8.2 (January 15, 2020) ###
* Catches exceptions when trying to connect to Redis [[#265](https://github.com/pantheon-systems/wp-redis/pull/265)].

### 0.8.1 (January 10, 2020) ###
* Adds `WP_REDIS_DEFAULT_EXPIRE_SECONDS` constant to set default cache expire value [[#264](https://github.com/pantheon-systems/wp-redis/pull/264)].

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"scripts": {
"lint": "@phpcs",
"phpcs": "vendor/bin/phpcs",
"phpcbf": "vendor/bin/phpcbf",
"phpunit": "vendor/bin/phpunit",
"test": "@phpunit"
}
Expand Down
20 changes: 12 additions & 8 deletions object-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -1002,14 +1002,18 @@ protected function _connect_redis() {
}
$client_parameters = $this->build_client_parameters( $redis_server );

$client_connection = array( $this, 'prepare_client_connection' );
/**
* Permits alternate initial client connection mechanism to be used.
*
* @param callable $client_connection Callback to execute.
*/
$client_connection = apply_filters( 'wp_redis_prepare_client_connection_callback', $client_connection );
$this->redis = call_user_func_array( $client_connection, array( $client_parameters ) );
try {
$client_connection = array( $this, 'prepare_client_connection' );
/**
* Permits alternate initial client connection mechanism to be used.
*
* @param callable $client_connection Callback to execute.
*/
$client_connection = apply_filters( 'wp_redis_prepare_client_connection_callback', $client_connection );
$this->redis = call_user_func_array( $client_connection, array( $client_parameters ) );
} catch ( Exception $e ) {
$this->_exception_handler( $e );
}

$keys_methods = array(
'auth' => 'auth',
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: getpantheon, danielbachhuber, mboynes, Outlandish Josh
Tags: cache, plugin, redis
Requires at least: 3.0.1
Tested up to: 5.3
Stable tag: 0.8.1
Stable tag: 0.8.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -107,6 +107,9 @@ There's a known issue with WordPress `alloptions` cache design. Specifically, a

== Changelog ==

= 0.8.2 (January 15, 2020) =
* Catches exceptions when trying to connect to Redis [[#265](https://github.com/pantheon-systems/wp-redis/pull/265)].

= 0.8.1 (January 10, 2020) =
* Adds `WP_REDIS_DEFAULT_EXPIRE_SECONDS` constant to set default cache expire value [[#264](https://github.com/pantheon-systems/wp-redis/pull/264)].

Expand Down
2 changes: 1 addition & 1 deletion wp-redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WP Redis
* Plugin URI: http://github.com/pantheon-systems/wp-redis/
* Description: WordPress Object Cache using Redis. Requires the PhpRedis extension (https://github.com/phpredis/phpredis).
* Version: 0.8.1
* Version: 0.8.2
* Author: Pantheon, Josh Koenig, Matthew Boynes, Daniel Bachhuber, Alley Interactive
* Author URI: https://pantheon.io/
*/
Expand Down

0 comments on commit dd58ff8

Please sign in to comment.