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

Catch exceptions when trying to connect to Redis #265

Merged
merged 6 commits into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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