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
427 stars 149 forks source link

Strange problems in docker setup #444

Closed hexclann closed 1 year ago

hexclann commented 1 year ago

Hello, I have a Wordpress and Redis running in two different containers. Redis can have upto 50 databases (defined in redis.conf), the WP container is connected to redis via phpredis. Here is the diagnostic data from the plugin:

Status: Connected
Client: PhpRedis (v5.3.7)
Drop-in: Valid
Disabled: No
Ping: 1
Errors: []
PhpRedis: 5.3.7
Relay: Not loaded
Predis: Not loaded
Credis: Not loaded
PHP Version: 8.2.4
Plugin Version: 2.2.4
Redis Version: 7.0.10
Multisite: No
Metrics: Enabled
Metrics recorded: 0
Filesystem: Working
Global Prefix: "wp_"
Blog Prefix: "wp_"
WP_REDIS_CLIENT: "phpredis"
WP_REDIS_HOST: "10.69.0.3"
WP_REDIS_DATABASE: "33"
WP_REDIS_TIMEOUT: "1"
WP_REDIS_READ_TIMEOUT: "1"
WP_REDIS_MAXTTL: "0"
WP_REDIS_PREFIX: "site1"
WP_REDIS_PLUGIN_PATH: "/var/www/html/wp-content/plugins/redis-cache"
Global Groups: [
    "blog-details",
    "blog-id-cache",
    "blog-lookup",
    "global-posts",
    "networks",
    "rss",
    "sites",
    "site-details",
    "site-lookup",
    "site-options",
    "site-transient",
    "users",
    "useremail",
    "userlogins",
    "usermeta",
    "user_meta",
    "userslugs",
    "redis-cache",
    "blog_meta",
    "code_snippets"
]
Ignored Groups: [
    "counts",
    "plugins",
    "themes"
]
Unflushable Groups: []
Groups Types: {
    "blog-details": "global",
    "blog-id-cache": "global",
    "blog-lookup": "global",
    "global-posts": "global",
    "networks": "global",
    "rss": "global",
    "sites": "global",
    "site-details": "global",
    "site-lookup": "global",
    "site-options": "global",
    "site-transient": "global",
    "users": "global",
    "useremail": "global",
    "userlogins": "global",
    "usermeta": "global",
    "user_meta": "global",
    "userslugs": "global",
    "redis-cache": "global",
    "counts": "ignored",
    "plugins": "ignored",
    "themes": "ignored",
    "blog_meta": "global",
    "code_snippets": "global"
}
Drop-ins: [
    "Redis Object Cache Drop-In v2.2.4 by Till Krüss"
]

Everything works in the dashboard; I have also verified the keys being stored in redis DB. But if I use wp-cli command to do any site operation while the Redis plugin is enabled I get the following error:

[28-Mar-2023 18:09:14 UTC] PHP Fatal error:  Uncaught Error: Class "Redis" not found in /var/www/html/wp-content/object-cache.php:696
Stack trace:
#0 /var/www/html/wp-content/object-cache.php(539): WP_Object_Cache->connect_using_phpredis(Array)
#1 /var/www/html/wp-content/object-cache.php(257): WP_Object_Cache->__construct(true)
#2 /var/www/html/wp-includes/load.php(730): wp_cache_init()
#3 /var/www/html/wp-settings.php(131): wp_start_object_cache()
#4 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1336): require('/var/www/html/w...')
#5 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1254): WP_CLI\Runner->load_wordpress()
#6 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
#7 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(78): WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\BootstrapState))
#8 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap()
#9 phar:///usr/local/bin/wp/php/boot-phar.php(11): include('phar:///usr/loc...')
#10 /usr/local/bin/wp(4): include('phar:///usr/loc...')
#11 {main}
  thrown in /var/www/html/wp-content/object-cache.php on line 696
Fatal error: Uncaught Error: Class "Redis" not found in /var/www/html/wp-content/object-cache.php:696
Stack trace:
#0 /var/www/html/wp-content/object-cache.php(539): WP_Object_Cache->connect_using_phpredis(Array)
#1 /var/www/html/wp-content/object-cache.php(257): WP_Object_Cache->__construct(true)
#2 /var/www/html/wp-includes/load.php(730): wp_cache_init()
#3 /var/www/html/wp-settings.php(131): wp_start_object_cache()
#4 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1336): require('/var/www/html/w...')
#5 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1254): WP_CLI\Runner->load_wordpress()
#6 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
#7 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(78): WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\BootstrapState))
#8 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap()
#9 phar:///usr/local/bin/wp/php/boot-phar.php(11): include('phar:///usr/loc...')
#10 /usr/local/bin/wp(4): include('phar:///usr/loc...')
#11 {main}
  thrown in /var/www/html/wp-content/object-cache.php on line 696
Error: There has been a critical error on this website.Learn more about troubleshooting WordPress. There has been a critical error on this website.

The GUI does not have any problem, but the wp-cli command fails even if I use --skip-plugins parameter. How to debug this?

tillkruss commented 1 year ago

You need to install PhpRedis:

Uncaught Error: Class "Redis" not found
hexclann commented 1 year ago

But the plugin was working fine according to the plugin page. If the phpredis is absent does the plugin fall back to another client?

tillkruss commented 1 year ago

It will use Predis if PhpRedis is not installed. Make sure CLI and FPM have the same extensions.