From 68fdd2a25789ad8d91ab94efc91b4385fc9bddb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Fri, 7 Jul 2023 01:14:00 +0200 Subject: [PATCH 1/3] Check source code for syntax errors in CI (#482) --- .github/workflows/lint.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 907a4e0e..386cc52e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -30,15 +30,18 @@ jobs: php-version: ${{ matrix.php }} extensions: msgpack, igbinary, mbstring, redis, relay coverage: none + tools: parallel-lint - name: Install PHP Dependencies uses: ramsey/composer-install@v2 + - name: Check source code for syntax errors + run: composer exec --no-interaction -- parallel-lint *.php dependencies/ includes/ tests/ + - name: Run PHPStan run: composer run phpstan editorconfig: - name: EditorConfig runs-on: ubuntu-latest timeout-minutes: 5 From 018c6d86119a83eb50456937129fabcab062c1d2 Mon Sep 17 00:00:00 2001 From: Martin Krcho <1962663+martinkrcho@users.noreply.github.com> Date: Fri, 21 Jul 2023 18:29:51 +0200 Subject: [PATCH 2/3] Handle unexpected result from Redis pipeline quietly. (#486) * Handle unexpected result from Redis pipeline quietly. * Match return value after getting unexpected result to be as expected. --- includes/object-cache.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/includes/object-cache.php b/includes/object-cache.php index 89545b9d..ac745c83 100644 --- a/includes/object-cache.php +++ b/includes/object-cache.php @@ -1299,7 +1299,8 @@ protected function add_multiple_at_once( array $data, $group = 'default', $expir }, $tx->{$method}() ?: [] ); if ( count( $results ) !== count( $keys ) ) { - throw new Exception( 'Redis pipeline returned unexpected result' ); + $tx->discard(); + return array_fill_keys( $keys, false ); } $results = array_combine( $keys, $results ); @@ -1548,7 +1549,8 @@ protected function delete_multiple_at_once( array $keys, $group = 'default' ) { }, $tx->{$method}() ?: [] ); if ( count( $results ) !== count( $keys ) ) { - throw new Exception( 'Redis pipeline returned unexpected result' ); + $tx->discard(); + return array_fill_keys( $keys, false ); } $execute_time = microtime( true ) - $start_time; @@ -2270,7 +2272,8 @@ protected function set_multiple_at_once( array $data, $group = 'default', $expir }, $tx->{$method}() ?: [] ); if ( count( $results ) !== count( $keys ) ) { - throw new Exception( 'Redis pipeline returned unexpected result' ); + $tx->discard(); + return array_fill_keys( $keys, false ); } $results = array_combine( $keys, $results ); From f9b58ce107d6dd679f07d010daa981eaf89fe29b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Kru=CC=88ss?= Date: Fri, 11 Aug 2023 13:07:31 -0700 Subject: [PATCH 3/3] tag v2.4.4 --- CHANGELOG.md | 4 ++++ includes/object-cache.php | 5 ++++- languages/redis-cache.pot | 16 ++++++++-------- readme.txt | 8 ++++++-- redis-cache.php | 2 +- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d52649d..4786ee55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 2.4.4 + +- Improved handling of unexpected transaction results + ## 2.4.3 - Fixed PHP `<=7.2` syntax error diff --git a/includes/object-cache.php b/includes/object-cache.php index ac745c83..001776e1 100644 --- a/includes/object-cache.php +++ b/includes/object-cache.php @@ -3,7 +3,7 @@ * Plugin Name: Redis Object Cache Drop-In * Plugin URI: https://wordpress.org/plugins/redis-cache/ * Description: A persistent object cache backend powered by Redis. Supports Predis, PhpRedis, Relay, replication, sentinels, clustering and WP-CLI. - * Version: 2.4.3 + * Version: 2.4.4 * Author: Till Krüss * Author URI: https://objectcache.pro * License: GPLv3 @@ -1300,6 +1300,7 @@ protected function add_multiple_at_once( array $data, $group = 'default', $expir if ( count( $results ) !== count( $keys ) ) { $tx->discard(); + return array_fill_keys( $keys, false ); } @@ -1550,6 +1551,7 @@ protected function delete_multiple_at_once( array $keys, $group = 'default' ) { if ( count( $results ) !== count( $keys ) ) { $tx->discard(); + return array_fill_keys( $keys, false ); } @@ -2273,6 +2275,7 @@ protected function set_multiple_at_once( array $data, $group = 'default', $expir if ( count( $results ) !== count( $keys ) ) { $tx->discard(); + return array_fill_keys( $keys, false ); } diff --git a/languages/redis-cache.pot b/languages/redis-cache.pot index 94e54642..ee01ff2a 100644 --- a/languages/redis-cache.pot +++ b/languages/redis-cache.pot @@ -2,14 +2,14 @@ # This file is distributed under the GPLv3. msgid "" msgstr "" -"Project-Id-Version: Redis Object Cache 2.4.3\n" +"Project-Id-Version: Redis Object Cache 2.4.4\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/redis-cache\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2023-06-29T10:40:20+00:00\n" +"POT-Creation-Date: 2023-08-11T20:06:44+00:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "X-Generator: WP-CLI 2.8.1\n" "X-Domain: redis-cache\n" @@ -294,30 +294,30 @@ msgstr "" msgid "Object cache drop-in could not be updated. Redis server is unreachable: %s" msgstr "" -#: includes/object-cache.php:2911 +#: includes/object-cache.php:2916 msgid "Error establishing a Redis connection" msgstr "" #. translators: %s = Formatted wp-config.php file name. -#: includes/object-cache.php:2918 +#: includes/object-cache.php:2923 msgid "WordPress is unable to establish a connection to Redis. This means that the connection information in your %s file are incorrect, or that the Redis server is not reachable." msgstr "" -#: includes/object-cache.php:2923 +#: includes/object-cache.php:2928 msgid "Is the correct Redis host and port set?" msgstr "" -#: includes/object-cache.php:2924 +#: includes/object-cache.php:2929 msgid "Is the Redis server running?" msgstr "" #. translators: %s = Link to installation instructions. -#: includes/object-cache.php:2929 +#: includes/object-cache.php:2934 msgid "If you need help, please read the installation instructions." msgstr "" #. translators: %1$s = Formatted object-cache.php file name, %2$s = Formatted wp-content directory name. -#: includes/object-cache.php:2936 +#: includes/object-cache.php:2941 msgid "To disable Redis, delete the %1$s file in the %2$s directory." msgstr "" diff --git a/readme.txt b/readme.txt index 83d06c8a..61d7209e 100644 --- a/readme.txt +++ b/readme.txt @@ -3,9 +3,9 @@ Contributors: tillkruess, a5hleyrich Donate link: https://github.com/sponsors/tillkruss Tags: redis, object cache, cache, object caching, caching performance, relay, predis, phpredis Requires at least: 3.3 -Tested up to: 6.2 +Tested up to: 6.3 Requires PHP: 7.2 -Stable tag: 2.4.3 +Stable tag: 2.4.4 License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0.html @@ -62,6 +62,10 @@ Redis Object Cache has various WP CLI commands, for more information run `wp hel == Changelog == += 2.4.4 = + +- Improved handling of unexpected transaction results + = 2.4.3 = - Fixed PHP `<=7.2` syntax error diff --git a/redis-cache.php b/redis-cache.php index 3fa881a0..b8a69ca1 100644 --- a/redis-cache.php +++ b/redis-cache.php @@ -3,7 +3,7 @@ * Plugin Name: Redis Object Cache * Plugin URI: https://wordpress.org/plugins/redis-cache/ * Description: A persistent object cache backend powered by Redis. Supports Predis, PhpRedis, Relay, replication, sentinels, clustering and WP-CLI. - * Version: 2.4.3 + * Version: 2.4.4 * Text Domain: redis-cache * Domain Path: /languages * Network: true