Pierre-Lannoy / wp-apcu-manager

APCu statistics and management right in the WordPress admin dashboard.
https://perfops.one/
GNU General Public License v3.0
5 stars 5 forks source link

Running cron jobs via WP CLI results in fatal error #5

Closed jfilter closed 1 year ago

jfilter commented 1 year ago

Describe the bug

Running cron jobs via WP CLI results in fatal error. See below.

To Reproduce

[wp1@spica ~]$ /usr/bin/wp cron event run --due-now --path=/var/www/virtual/wp1/html
Executed the cron event 'opcm_watchdog' in 0.029s.
Executed the cron event 'wp_cache_gc_watcher' in 0.022s.
[17-Jan-2023 23:36:09 UTC] PHP Warning:  apcu_cache_info(): No APC info available.  Perhaps APC is not enabled? Check apc.enabled in your ini file in /var/www/virtual/wp1/html/wp-content/plugins/apcu-manager/includes/features/class-capture.php on line 71
Warning: apcu_cache_info(): No APC info available.  Perhaps APC is not enabled? Check apc.enabled in your ini file in /var/www/virtual/wp1/html/wp-content/plugins/apcu-manager/includes/features/class-capture.php on line 71
[17-Jan-2023 23:36:09 UTC] PHP Fatal error:  Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, bool given in /var/www/virtual/wp1/html/wp-content/plugins/apcu-manager/includes/features/class-capture.php:72
Stack trace:
#0 /var/www/virtual/wp1/html/wp-content/plugins/apcu-manager/includes/features/class-capture.php(72): array_key_exists('cache_list', false)
#1 /var/www/virtual/wp1/html/wp-content/plugins/apcu-manager/includes/features/class-capture.php(214): APCuManager\Plugin\Feature\Capture::get_details()
#2 /var/www/virtual/wp1/html/wp-includes/class-wp-hook.php(308): APCuManager\Plugin\Feature\Capture::check()
#3 /var/www/virtual/wp1/html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array)
#4 /var/www/virtual/wp1/html/wp-includes/plugin.php(565): WP_Hook->do_action(Array)
#5 phar:///usr/bin/wp/vendor/wp-cli/cron-command/src/Cron_Event_Command.php(343): do_action_ref_array('apcm_apcu_stats', Array)
#6 phar:///usr/bin/wp/vendor/wp-cli/cron-command/src/Cron_Event_Command.php(265): Cron_Event_Command::run_event(Object(stdClass))
#7 [internal function]: Cron_Event_Command->run(Array, Array)
#8 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(100): call_user_func(Array, Array, Array)
#9 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}(Array, Array)
#10 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(491): call_user_func(Object(Closure), Array, Array)
#11 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(419): WP_CLI\Dispatcher\Subcommand->invoke(Array, Array, Array)
#12 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(442): WP_CLI\Runner->run_command(Array, Array)
#13 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1256): WP_CLI\Runner->run_command_and_exit()
#14 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
#15 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(78): WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\BootstrapState))
#16 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap()
#17 phar:///usr/bin/wp/php/boot-phar.php(11): include('phar:///usr/bin...')
#18 /usr/bin/wp(4): include('phar:///usr/bin...')
#19 {main}
  thrown in /var/www/virtual/wp1/html/wp-content/plugins/apcu-manager/includes/features/class-capture.php on line 72
Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, bool given in /var/www/virtual/wp1/html/wp-content/plugins/apcu-manager/includes/features/class-capture.php:72
Stack trace:
#0 /var/www/virtual/wp1/html/wp-content/plugins/apcu-manager/includes/features/class-capture.php(72): array_key_exists('cache_list', false)
#1 /var/www/virtual/wp1/html/wp-content/plugins/apcu-manager/includes/features/class-capture.php(214): APCuManager\Plugin\Feature\Capture::get_details()
#2 /var/www/virtual/wp1/html/wp-includes/class-wp-hook.php(308): APCuManager\Plugin\Feature\Capture::check()
#3 /var/www/virtual/wp1/html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array)
#4 /var/www/virtual/wp1/html/wp-includes/plugin.php(565): WP_Hook->do_action(Array)
#5 phar:///usr/bin/wp/vendor/wp-cli/cron-command/src/Cron_Event_Command.php(343): do_action_ref_array('apcm_apcu_stats', Array)
#6 phar:///usr/bin/wp/vendor/wp-cli/cron-command/src/Cron_Event_Command.php(265): Cron_Event_Command::run_event(Object(stdClass))
#7 [internal function]: Cron_Event_Command->run(Array, Array)
#8 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(100): call_user_func(Array, Array, Array)
#9 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}(Array, Array)
#10 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(491): call_user_func(Object(Closure), Array, Array)
#11 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(419): WP_CLI\Dispatcher\Subcommand->invoke(Array, Array, Array)
#12 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(442): WP_CLI\Runner->run_command(Array, Array)
#13 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1256): WP_CLI\Runner->run_command_and_exit()
#14 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
#15 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(78): WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\BootstrapState))
#16 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap()
#17 phar:///usr/bin/wp/php/boot-phar.php(11): include('phar:///usr/bin...')
#18 /usr/bin/wp(4): include('phar:///usr/bin...')
#19 {main}
  thrown in /var/www/virtual/wp1/html/wp-content/plugins/apcu-manager/includes/features/class-capture.php on line 72

Environment:

Additional context

Please let me know if you need additional information. Thanks for your work.

Pierre-Lannoy commented 1 year ago

Hello @jfilter ! Thanks a lot for your report. It will be fixed in the next release (before end of feb.) In the meantime, if you want to avoid such issue, you have to enable APCu for your command line php version…

Pierre-Lannoy commented 1 year ago

Hello @jfilter ! Could you confirm the new release (3.4.1) of APCu Manager fixes your issue? Thanks ;)

jfilter commented 1 year ago

Yes, thanks!