Repository navigation
Let a failed app.php load fail with a non-zero status - #1112
Merged
Merged
Conversation
bootstrap.php caught the exception from loading config/app.php and passed its message to exit(). exit() with a string prints it and ends with status 0, so a broken config made bin/cake commands report success, and the web SAPI answered 200 with the message in the body and nothing in the log. The error and exception traps are not registered yet at this point, since they need the Error config from app.php. Dropping the catch leaves the exception to PHP: status 255 on the CLI, a logged 500 on the web, with the output governed by display_errors and log_errors.
Member
Author
|
Actually, maybe a safer "web" way would be to do what PHP itself does here? |
Keep the catch, but end with a failure: on the CLI the message goes to stderr and the exit status is 1, on the web the message is written to the error log and the response is a 500 with an empty body. This keeps the one-line CLI output instead of a stack trace, and never shows the message or file paths to visitors regardless of display_errors. error_log() is skipped on the CLI because its default destination there is stderr, which printed the message twice.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1111.
config/bootstrap.phpcaught the exception from loadingconfig/app.phpand passed its message toexit(). With a string argument,exit()prints the string and ends with status 0. A brokenapp.phptherefore madebin/cakecommands report success, and on the web the message went out in a 200 response without reaching the error log.The catch stays, but now ends with a failure.
ErrorTrapandExceptionTrapcannot handle it, since they are registered further down and need theErrorconfig fromapp.php, so the failure is reported by hand:display_errorssays.With
config/app.phpchanged toreturn null;:bin/cake versionGET /(built-in server)