The plugin is causing WP-CLI to fail. Here is the error using a simple WP-CLI command:
$ wp maintenance-mode status
Fatal error: Uncaught Error: Class "QM_Collector_DB_Queries" not found in /var/www/example.com/htdocs/wp-content/plugins/query-monitor-save-post-queries/php/Collector_Save_Post_Queries.php:14
Stack trace:
#0 /var/www/example.com/htdocs/wp-content/plugins/query-monitor-save-post-queries/query-monitor-save-post-queries.php(71): require_once()
#1 /var/www/example.com/htdocs/wp-includes/class-wp-hook.php(324): qmspq_plugin_setup()
#2 /var/www/example.com/htdocs/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#3 /var/www/example.com/htdocs/wp-includes/plugin.php(517): WP_Hook->do_action()
#4 /var/www/example.com/htdocs/wp-settings.php(678): do_action()
#5 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1374): require('...')
#6 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1293): WP_CLI\Runner->load_wordpress()
#7 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
#8 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(83): WP_CLI\Bootstrap\LaunchRunner->process()
#9 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap()
#10 phar:///usr/local/bin/wp/php/boot-phar.php(20): include('...')
#11 /usr/local/bin/wp(4): include('...')
#12 {main}
thrown in /var/www/example.com/htdocs/wp-content/plugins/query-monitor-save-post-queries/php/Collector_Save_Post_Queries.php on line 14
Error: There has been a critical error on this website.Learn more about troubleshooting WordPress. There has been a critical error on this website.
Steps To Reproduce
Install plugin, run any WP-CLI command from the command line.
if ( 'cli' === php_sapi_name() && ! defined( 'QM_TESTS' ) ) {
# For the time being, let's not load QM when using the CLI because we've no persistent storage and no means of
# outputting collected data on the CLI. This will hopefully change in a future version of QM.
return;
}
Description of the bug
The plugin is causing WP-CLI to fail. Here is the error using a simple WP-CLI command:
Steps To Reproduce
Install plugin, run any WP-CLI command from the command line.
Additional Information
If you look in Query Monitor's main bootstrap file, it includes a block of code that ensures it doesn't run via WP-CLI:
Adding this code to
query-monitor-save-post-queries.php
at line 67 did solve this issue for me.While on the subject, it might also be wise to add some of Query Monitor's other conditionals for not running in that file as well. I do see you already have a check for
QM_DISABLED
on line 63. Or maybe what we really here is to use different hooks, such as using theqm/collectors
to register the collector (here's an example usage in another Query Monitor extension plugin) instead of using theafter_setup_theme
hook (line 97).