pantheon-systems / wp-redis

WordPress Object Cache using Redis.
https://wordpress.org/plugins/wp-redis/
GNU General Public License v2.0
225 stars 67 forks source link

Fatal error in WP-CLI when accessing cache #410

Closed jazzsequence closed 1 year ago

jazzsequence commented 1 year ago

Since 1.4.0, WP Redis will generate a fatal error when cache functions are accessed from WP-CLI (possibly from runtime as well). This issue does not exist in 1.3.5 (the last 1.3.x release).

Steps to reproduce

  1. wp plugin install wp-redis --activate
  2. wp redis enable
  3. wp redis flush or wp cache flush

Result:

PHP Fatal error:  Uncaught Error: Call to a member function get() on null in /app/wp-content/plugins/wp-redis/object-cache.php:139
Stack trace:
#0 /app/wp-includes/option.php(165): wp_cache_get('notoptions', 'options')
#1 /app/wp-includes/formatting.php(1107): get_option('blog_charset')
#2 /app/wp-includes/formatting.php(4577): wp_check_invalid_utf8('WP Redis: Conne...')
#3 /app/wp-content/plugins/wp-redis/object-cache.php(1471): esc_html('WP Redis: Conne...')
#4 /app/wp-content/plugins/wp-redis/object-cache.php(1185): WP_Object_Cache->_exception_handler(Object(RedisException))
#5 /app/wp-content/plugins/wp-redis/object-cache.php(1510): WP_Object_Cache->_connect_redis()
#6 /app/wp-content/plugins/wp-redis/object-cache.php(215): WP_Object_Cache->__construct()
#7 /app/wp-includes/load.php(750): wp_cache_init()
#8 /app/wp-settings.php(131): wp_start_object_cache()
#9 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1336): require('/app/wp-setting...')
#10 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1254): WP_CLI\Runner->load_wordpress()
#11 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
#12 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(78): WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\BootstrapState))
#13 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap()
#14 phar:///usr/local/bin/wp/php/boot-phar.php(11): include('phar:///usr/loc...')
#15 /usr/local/bin/wp(4): include('phar:///usr/loc...')
#16 {main}
  thrown in /app/wp-content/plugins/wp-redis/object-cache.php on line 139
Error: There has been a critical error on this website.Learn more about troubleshooting WordPress. There has been a critical error on this website.                                                                                                                          

Tracked internally in CMSP-390

spacedmonkey commented 1 year ago

https://core.trac.wordpress.org/ticket/56639

pwtyler commented 1 year ago

Unable to reproduce this on my local machine when Redis is not enabled (my working assumption up until now), see WIP script in #415.

This exits gracefully with

Error: Warning! PHPRedis extension is unavailable, which is required by WP Redis object cache.

EDIT: #418 clarified I needed to be one step further and now reproducing.

pwtyler commented 1 year ago

This is fixed in 1.4.2, now live on .org