doctor-command icon indicating copy to clipboard operation
doctor-command copied to clipboard

Fails on older themes with the `--skip-themes` option

Open nostamp opened this issue 2 years ago • 2 comments

When running wp doctor check with the --skip-themes option on older themes (twentytwelve v4.1) can cause a fatal error. Switching to a newer theme for example works however working my way upt from twentytwelve the first theme that does not throw the fatal error is twentytwentytwo v1.6, every theme older than that appears to throw an error.

wp doctor check autoload-options-size --skip-themes --skip-plugins | head                                                                                                                                
PHP Fatal error:  Uncaught Error: Call to undefined function twentytwelve_entry_meta() in /home/wp_269mgp/dhctest1.boop.com/wp-content/themes/twentytwelve/content.php:59                                                                             
Stack trace:                                                                                                                                                                                                                                               
#0 /home/wp_269mgp/dhctest1.boop.com/wp-includes/template.php(792): require()                                                                                                                                                                         
#1 /home/wp_269mgp/dhctest1.boop.com/wp-includes/template.php(725): load_template('/home/wp_269mgp...', false, Array)                                                                                                                                 
#2 /home/wp_269mgp/dhctest1.boop.com/wp-includes/general-template.php(206): locate_template(Array, true, false, Array)                                                                                                                                
#3 /home/wp_269mgp/dhctest1.boop.com/wp-content/themes/twentytwelve/index.php(28): get_template_part('content', '')                                                                                                                                   
#4 /home/wp_269mgp/dhctest1.boop.com/wp-includes/template-loader.php(106): include('/home/wp_269mgp...')                                                                                                                                              
#5 /usr/local/wp/vendor/wp-cli/doctor-command/inc/class-command.php(354): require_once('/home/wp_269mgp...')                                                                                                                                               
#6 /usr/local/wp/vendor/wp-cli/doctor-command/inc/class-command.php(168): runcommand\Doctor\Command->load_wordpress_with_template()                                                                                                                        
#7 [internal function]: runcommand\Doctor\Command->check(Array, Array)                                                                                                                                                                                     
#8 /usr/local/wp/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 /usr/local/wp/php/WP_CLI/Dispatcher/Subcommand.php(488): call_user_func(Object(Closure), Array, Array)                                                                                                                                                 
#11 /usr/local/wp/php/WP_CLI/Runner.php(437): WP_CLI\Dispatcher\Subcommand->invoke(Array, Array, Array)                                                                                                                                                    
#12 /usr/local/wp/php/WP_CLI/Runner.php(460): WP_CLI\Runner->run_command(Array, Array)                                                                                                                                                                     
#13 /usr/local/wp/php/WP_CLI/Runner.php(136): WP_CLI\Runner->run_command_and_exit()                                                                                                                                                                        
#14 /usr/local/wp/php/WP_CLI/Runner.php(1219): WP_CLI\Runner->do_early_invoke('before_wp_load')                                                                                                                                                            
#15 /usr/local/wp/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()                                                                                                                                                                        
#16 /usr/local/wp/php/bootstrap.php(83): WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\BootstrapState))                                                                                                                                   
#17 /usr/local/wp/php/wp-cli.php(32): WP_CLI\bootstrap()                                                                     
#18 /usr/local/wp/php/boot-fs.php(17): require_once('/usr/local/wp/p...')                                                                                                                                                                                  
#19 {main}
OS:     Linux 5.15.0-1046-kvm #51-Ubuntu SMP Fri Oct 6 17:10:13 UTC 2023 x86_64
Shell:  /bin/bash
PHP binary:     /usr/local/php81/bin/php
PHP version:    8.1.25
php.ini used:   /etc/php81/php.ini
MySQL binary:   /usr/bin/mysql
MySQL version:  mysql  Ver 8.0.34-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))
SQL modes:
WP-CLI root dir:        /usr/local/wp
WP-CLI vendor dir:      /usr/local/wp/vendor
WP_CLI phar path:
WP-CLI packages dir:
WP-CLI cache dir:       /home/wp_269mgp/.wp-cli/cache
WP-CLI global config:   /usr/local/wp/config.yml
WP-CLI project config:
WP-CLI version: 2.9.0

nostamp avatar Dec 06 '23 00:12 nostamp

--skip-themes is a global argument in WP-CLI to skip loading the theme. However, the doctor check command deliberately forces WordPress to be loaded with a theme:

https://github.com/wp-cli/doctor-command/blob/1c46617b8df15d3cd543213a7ab6ad6d050774f2/inc/class-command.php#L304-L356

So the two are not really compatible.

While the command could be adapted to manually load the theme's functions.php in that case, it's probably much simpler to just document that it can't be used in combination with --skip-themes.

What's the reason you are using --skip-themes in this instance?

swissspidy avatar Dec 06 '23 13:12 swissspidy

Thank you for the response. I was unaware of the compatibility issues. That --skip-themes flag ended up working its way into my notes as I run other commands with --skip-themes --skip-plugins when checking some core things.

Thank you kindly for the information. I will update my notes and discontinue the use.

nostamp avatar Dec 06 '23 15:12 nostamp