Skip to content

Top level themes/functions.php file breaks --skip-themes #5240

@austinginder

Description

@austinginder

For compatibility I'm using --skip-themes when fetching plugin details. The actual command I run looks like this wp plugin list --format=json --skip-themes --skip-plugins --skip-packages --fields=name,title,status,version. However this issue looks more generic. Here are steps to reproduce.

  1. Create an empty WordPress 5.5.2 site running WP-CLI 2.2.0
  2. Create a functions.php file with a syntax error or an undefined function like <?php genesis_register_sidebar(); and place under /wp-content/themes/
  3. Attempt to run wp plugin list --skip-themes

I'd expect this to work as it's skipping themes however it seems functions.php is special and gets triggered resulting in the following output.

PHP Fatal error:  Uncaught Error: Call to undefined function genesis_register_sidebar() in /Users/username/Sites/wordpress/wp-content/themes/functions.php:3
Stack trace:
#0 /Users/username/Sites/wordpress/wp-settings.php(499): include()
#1 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1209): require('/Users/austingi...')
#2 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1130): WP_CLI\Runner->load_wordpress()
#3 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(23): WP_CLI\Runner->start()
#4 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(74): WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\BootstrapState))
#5 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(27): WP_CLI\bootstrap()
#6 phar:///usr/local/bin/wp/php/boot-phar.php(11): include('phar:///usr/loc...')
#7 /usr/local/bin/wp(4): include('phar:///usr/loc...')
#8 {main}
  thrown in /Users/username/Sites/wordpress/wp-content/themes/functions.php on line 3
Fatal error: Uncaught Error: Call to undefined function genesis_register_sidebar() in /Users/username/Sites/wordpress/wp-content/themes/functions.php:3
Stack trace:
#0 /Users/username/Sites/wordpress/wp-settings.php(499): include()
#1 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1209): require('/Users/austingi...')
#2 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1130): WP_CLI\Runner->load_wordpress()
#3 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(23): WP_CLI\Runner->start()
#4 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(74): WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\BootstrapState))
#5 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(27): WP_CLI\bootstrap()
#6 phar:///usr/local/bin/wp/php/boot-phar.php(11): include('phar:///usr/loc...')
#7 /usr/local/bin/wp(4): include('phar:///usr/loc...')
#8 {main}
  thrown in /Users/username/Sites/wordpress/wp-content/themes/functions.php on line 3
Error: The site is experiencing technical difficulties.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions