rhubarbgroup / redis-cache

A persistent object cache backend for WordPress powered by Redis. Supports Predis, PhpRedis, Relay, replication, sentinels, clustering and WP-CLI.
https://wordpress.org/plugins/redis-cache/
GNU General Public License v3.0
425 stars 148 forks source link

wp_cache_flush_group fails on 2.5.2 #519

Closed Trisky closed 4 months ago

Trisky commented 4 months ago

Description

Using predis + redis cluster.

It seems that the new version it has issues doing wp_cache_flush_group. Started happening after upgrading from 2.5.0 to 2.5.2

/www/web$ wp eval 'wp_cache_flush_group("a");' --skip-plugins --skip-themes
PHP Fatal error:  Uncaught Error: Call to undefined method Predis\Connection\Replication\SentinelReplication::getParameters() in /var/www/html/www/web/app/object-cache.php:1607
Stack trace:
#0 /var/www/html/www/web/app/object-cache.php(1783): WP_Object_Cache->execute_lua_script(Object(Closure))
#1 /var/www/html/www/web/app/object-cache.php(162): WP_Object_Cache->flush_group('a')
#2 phar:///usr/local/bin/wp/vendor/wp-cli/eval-command/src/Eval_Command.php(39) : eval()'d code(1): wp_cache_flush_group('a')
#3 phar:///usr/local/bin/wp/vendor/wp-cli/eval-command/src/Eval_Command.php(39): eval()
#4 [internal function]: Eval_Command->__invoke(Array, Array)
#5 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(100): call_user_func(Array, Array, Array)
#6 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}(Array, Array)
#7 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(497): call_user_func(Object(Closure), Array, Array)
#8 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(441): WP_CLI\Dispatcher\Subcommand->invoke(Array, Array, Array)
#9 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(464): WP_CLI\Runner->run_command(Array, Array)
#10 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(136): WP_CLI\Runner->run_command_and_exit()
#11 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1228): WP_CLI\Runner->do_early_invoke('before_wp_load')
#12 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
#13 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(83): WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\BootstrapState))
#14 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap()
#15 phar:///usr/local/bin/wp/php/boot-phar.php(20): include('phar:///usr/loc...')
#16 /usr/local/bin/wp(4): include('phar:///usr/loc...')
#17 {main}
  thrown in /var/www/html/www/web/app/object-cache.php on line 1607

Expected Behavior

No errors

Actual Behavior

Uncaught Error: Call to undefined method Predis\Connection\Replication\SentinelReplication::getParameters() error

Possible Fix

Fix the bug and add a unit test case? (seems to be missing for cache flush group?)

Steps to Reproduce

  1. Run in the terminal to get the error: wp eval 'wp_cache_flush_group("a");' --skip-plugins --skip-themes

Additional context

Environment

tillkruss commented 4 months ago

@yatsukhnenko: Can you take a look at this. It's probably due to our new lua closures and we didn't test Sentinel enough.

yatsukhnenko commented 4 months ago

@Trisky can you provide configuration which you use so I could replicate issue locally?

Trisky commented 4 months ago

I'm using predis + sentinel. My config looks like this:

WP_REDIS_SENTINEL: website-master
WP_REDIS_DISABLE_DROPIN_AUTOUPDATE: true
WP_REDIS_CLIENT: predis
WP_REDIS_METRICS_MAX_TIME: 10800
WP_REDIS_SERVERS: ['tcp://xxx1.local:26379','tcp://xxx2.local:26379','tcp://xxx3.local:26379']

Plugins and themes installed are kinda irrelevant since it happens with --skip-plugins --skip-themes in the CLI :)

yatsukhnenko commented 4 months ago

OK, the fix in #520 works but there is another problem with sentinel replication connection

PHP Deprecated:  version_compare(): Passing null to parameter #1 ($version1) of type string is deprecated in /var/www/html/wp-content/object-cache.php

@tillkruss should I create another issue for it or just add another commit to my PR?

tillkruss commented 4 months ago

@yatsukhnenko Yes please 👍