From 53064f5ebed896b7d92c9404c8ec68e3c99b560d Mon Sep 17 00:00:00 2001 From: Mathieu Hays Date: Fri, 22 Nov 2019 13:19:06 +0100 Subject: [PATCH 1/4] fix #226 wrap connect call in try/catch --- object-cache.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/object-cache.php b/object-cache.php index 12d3ff5..b0a3070 100644 --- a/object-cache.php +++ b/object-cache.php @@ -998,14 +998,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', From ea9b79361685984fb9001718f81237f52ef18fef Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Wed, 15 Jan 2020 10:47:15 -0800 Subject: [PATCH 2/4] Add a shortcut for `phpcbf` --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index db376b5..a58079b 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,7 @@ "scripts": { "lint": "@phpcs", "phpcs": "vendor/bin/phpcs", + "phpcbf": "vendor/bin/phpcbf", "phpunit": "vendor/bin/phpunit", "test": "@phpunit" } From 76cf7a071a0e753a728061b234ac6951f5c7373d Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Wed, 15 Jan 2020 10:47:48 -0800 Subject: [PATCH 3/4] Clean up PHPCS issues --- object-cache.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/object-cache.php b/object-cache.php index 278f0ff..3627a3b 100644 --- a/object-cache.php +++ b/object-cache.php @@ -999,14 +999,14 @@ protected function _connect_redis() { $client_parameters = $this->build_client_parameters( $redis_server ); try { - $client_connection = array($this, 'prepare_client_connection'); + $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)); + $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 ); } From 22011735f04d7262a4f241ee7b88935b03f7c3fc Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Wed, 15 Jan 2020 10:53:17 -0800 Subject: [PATCH 4/4] Update README for v0.8.2 --- README.md | 5 ++++- readme.txt | 5 ++++- wp-redis.php | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9b5ad53..b1005e7 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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)]. diff --git a/readme.txt b/readme.txt index c00a36a..11a9360 100644 --- a/readme.txt +++ b/readme.txt @@ -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 @@ -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)]. diff --git a/wp-redis.php b/wp-redis.php index 64c9f43..231d422 100644 --- a/wp-redis.php +++ b/wp-redis.php @@ -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/ */