-
Notifications
You must be signed in to change notification settings - Fork 998
Display a custom error message when themes/functions.php
fatals
#5817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to say it's quite the edge case but alas 🤷♂️
@@ -100,7 +100,7 @@ function wp_die_handler( $message ) { | |||
$error_data = $message->get_error_data( 'internal_server_error' ); | |||
if ( ! empty( $error_data['error']['file'] ) | |||
&& false !== stripos( $error_data['error']['file'], 'themes/functions.php' ) ) { | |||
$text_message = 'There was an internal server error that may have been caused by an unexpected functions.php file in the themes directory.'; | |||
$text_message = 'An unexpected functions.php file in the themes directory may have caused this internal server error.'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, what about the original error message? Shouldn't that be kept and displayed as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@schlessera I don't think the original error message is particularly helpful.
Original output
$ wp --skip-themes option get home
Fatal error: Uncaught Error: Call to undefined function genesis_register_sidebar() in /Users/danielbachhuber/projects/vanilla/wp-content/themes/functions.php:3
Stack trace:
#0 /Users/danielbachhuber/projects/vanilla/wp-settings.php(600): include()
#1 /Users/danielbachhuber/projects/wp-cli-dev/wp-cli/php/WP_CLI/Runner.php(1349): require('/Users/danielba...')
#2 /Users/danielbachhuber/projects/wp-cli-dev/wp-cli/php/WP_CLI/Runner.php(1267): WP_CLI\Runner->load_wordpress()
#3 /Users/danielbachhuber/projects/wp-cli-dev/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
#4 /Users/danielbachhuber/projects/wp-cli-dev/wp-cli/php/bootstrap.php(83): WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\BootstrapState))
#5 /Users/danielbachhuber/projects/wp-cli-dev/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap()
#6 /Users/danielbachhuber/projects/wp-cli-dev/wp-cli/php/boot-fs.php(17): require_once('/Users/danielba...')
#7 {main}
thrown in /Users/danielbachhuber/projects/vanilla/wp-content/themes/functions.php on line 3
Error: There has been a critical error on this website.Learn more about troubleshooting WordPress. There has been a critical error on this website.
New output
$ wp --skip-themes option get home
Fatal error: Uncaught Error: Call to undefined function genesis_register_sidebar() in /Users/danielbachhuber/projects/vanilla/wp-content/themes/functions.php:3
Stack trace:
#0 /Users/danielbachhuber/projects/vanilla/wp-settings.php(600): include()
#1 /Users/danielbachhuber/projects/wp-cli-dev/wp-cli/php/WP_CLI/Runner.php(1349): require('/Users/danielba...')
#2 /Users/danielbachhuber/projects/wp-cli-dev/wp-cli/php/WP_CLI/Runner.php(1267): WP_CLI\Runner->load_wordpress()
#3 /Users/danielbachhuber/projects/wp-cli-dev/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
#4 /Users/danielbachhuber/projects/wp-cli-dev/wp-cli/php/bootstrap.php(83): WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\BootstrapState))
#5 /Users/danielbachhuber/projects/wp-cli-dev/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap()
#6 /Users/danielbachhuber/projects/wp-cli-dev/wp-cli/php/boot-fs.php(17): require_once('/Users/danielba...')
#7 {main}
thrown in /Users/danielbachhuber/projects/vanilla/wp-content/themes/functions.php on line 3
Error: An unexpected functions.php file in the themes directory may have caused this internal server error.
@danielbachhuber Hmm looks like the automated tests for the Phar build are now failing because of this: https://github.com/wp-cli/automated-tests/actions/runs/5885136682/job/15961097291#step:14:263 |
@swissspidy I think updating the bundle should fix wp-cli/wp-cli-bundle#566 |
@danielbachhuber doesn't look like it, see this latest run: https://github.com/wp-cli/automated-tests/actions/runs/5903479397/job/16013536710 What am I missing? |
@swissspidy It looks like the tests are running against the nightly Phar build, but it's not being deployed right now wp-cli/wp-cli-bundle#568 |
@swissspidy Fixed now https://github.com/wp-cli/automated-tests/actions/runs/5903479397 Thanks for flagging! |
Fixes #5240
Trying to fix this upstream is too much of a rabbit hole. Instead, let's give the user a more helpful pointer: