rhubarbgroup / .github

Community Health Files
https://github.com/rhubarbgroup/
0 stars 0 forks source link

Uncaught RedisException #6

Closed delitestudio closed 1 year ago

delitestudio commented 1 year ago

With the latest version of Redis Object Cache (v2.3.0), an unhandled exception is thrown in case of database connection problems:

PHP Fatal error:  Uncaught RedisException: Connection refused in /public_html/wp-content/object-cache.php:726
Stack trace:
#0 /public_html/wp-content/object-cache.php(726): Redis->connect()
rhubarbgroup/redis-cache#1 /public_html/wp-content/object-cache.php(538): WP_Object_Cache->connect_using_phpredis()
rhubarbgroup/redis-cache#2 /public_html/wp-content/object-cache.php(256): WP_Object_Cache->__construct()
rhubarbgroup/redis-cache#3 /public_html/wp-includes/load.php(750): wp_cache_init()
rhubarbgroup/redis-cache#4 /public_html/wp-settings.php(131): wp_start_object_cache()
rhubarbgroup/redis-cache#5 /public_html/wp-config.php(172): require_once('/home/...')
rhubarbgroup/redis-cache#6 /public_html/wp-load.php(50): require_once('/home/...')
rhubarbgroup/redis-cache#7 /public_html/wp-blog-header.php(13): require_once('/home/...')
rhubarbgroup/redis-cache#8 /public_html/index.php(17): require('/home/...')
rhubarbgroup/redis-cache#9 {main}
  thrown in /public_html/wp-content/object-cache.php on line 726

This brings up the WordPress error screen instead of the more correct db-error.php. It didn't happen with previous versions.

tillkruss commented 1 year ago

We're aware.

delitestudio commented 1 year ago

Ok, thanks for the reply! So, just to understand, it's something that will be fixed in the next releases?

tillkruss commented 1 year ago

The next release will show you "Uncaught RedisException: Connection refused" very clearly, but your issue is that you need to ensure Redis Object Cache is configured to talk to Redis, which is doesn't appear to be.

delitestudio commented 1 year ago

Sorry, not sure I understand. So it's not a problem with the plugin Redis Object Cache, but some error on our side?

tillkruss commented 1 year ago

Correct.

delitestudio commented 1 year ago

Not sure, because with previous versions of the plugin it didn't happen... In general I believe that an exception of that type should be handled gracefully, not through a fatal error... Don't you?

delitestudio commented 1 year ago

Analyzing the source code it could be due to this recent change in the includes/object-cache.php file, from:

public function __construct( $fail_gracefully = true ) { ... }

to:

public function __construct( $fail_gracefully = false ) { ... }

Perhaps setting this define into the wp-config.php might solve the problem?

define( 'WP_REDIS_GRACEFUL', true );

Thanks?