wp-cli: WP CLI throws an error with wp plugin list saying WP_CLI class not found when it is?
Bug Report
- Yes, I reviewed the contribution guidelines.
- Yes, more specifically, I reviewed the guidelines on how to write clear bug reports.
Describe the current, buggy behavior
When running wp plugin list, the following errors occur:
Fatal error: Uncaught Error: Class "WP_CLI" not found in /var/www/vhosts/buyterpenesonline.com/wp-content/plugins/woocommerce-product-feeds/vendor/woocommerce/action-scheduler/classes/abstracts/ActionScheduler.php:168
Stack trace:
#0 /var/www/vhosts/buyterpenesonline.com/wp-content/plugins/woocommerce-product-feeds/vendor/woocommerce/action-scheduler/action-scheduler.php(44): ActionScheduler::init()
#1 /var/www/vhosts/buyterpenesonline.com/wp-content/plugins/woocommerce-customer-order-csv-export/vendor/woocommerce/action-scheduler/classes/ActionScheduler_Versions.php(59): action_scheduler_initialize_3_dot_1_dot_6()
#2 /var/www/vhosts/buyterpenesonline.com/wp-includes/class-wp-hook.php(285): ActionScheduler_Versions::initialize_latest_version()
#3 /var/www/vhosts/buyterpenesonline.com/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters()
#4 /var/www/vhosts/buyterpenesonline.com/wp-includes/plugin.php(484): WP_Hook->do_action()
#5 /var/www/vhosts/buyterpenesonline.com/wp-settings.php(420): do_action()
#6 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1237): require('...')
#7 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1158): WP_CLI\Runner->load_wordpress()
#8 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(23): WP_CLI\Runner->start()
#9 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(74): WP_CLI\Bootstrap\LaunchRunner->process()
#10 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(27): WP_CLI\bootstrap()
#11 phar:///usr/bin/wp/php/boot-phar.php(11): include('...')
#12 /usr/bin/wp(4): include('...')
#13 {main}
thrown in /var/www/vhosts/buyterpenesonline.com/wp-content/plugins/woocommerce-product-feeds/vendor/woocommerce/action-scheduler/classes/abstracts/ActionScheduler.php on line 168
Error: There has been a critical error on this website.Learn more about debugging in WordPress. There has been a critical error on this website.
Describe what you expect as the correct outcome
A clear and concise description of what you expected to happen (or code).
Let us know what environment you are running this on
centos 7.9 php 8.0.5
OS: Linux 3.10.0-862.14.4.el7.x86_64 #1 SMP Wed Sep 26 15:12:11 UTC 2018 x86_64
Shell: /bin/bash
PHP binary: /opt/remi/php80/root/usr/bin/php
PHP version: 8.0.5
php.ini used: /etc/opt/remi/php80/php.ini
WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /var/www/vhosts/buyterpenesonline.com
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.4.0
Provide a possible solution
If you happen to have a suggestion on how to fix this bug, please tell us in here.
Just leave this section out if you don’t know how to fix it.
Provide additional context/screenshots
Add any other context about the problem here.
If applicable, add screenshots to help explain (you can just drag&drop images into the Github issue).
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (5 by maintainers)
Good find, @barrychapman, that is the root issue of your problem.
The opcache caches parsed PHP files based on their filesystem path. This means that as long as the opcache is active, modifying files on the filesystem or moving them around immediately breaks the code until the opcache is reset, as you’ll end up with portions of the code in the opcache and portions that have not yet been cached, and these two don’t properly match up.
You can also take a look at this SO entry for more insights: https://stackoverflow.com/a/35880017
By its very nature, the opcache is something that you should only enable if you also invalidate the cache on filesystem modifications.
I’m closing this issue as this is not directly related to WP-CLI.