I\'m running PHP 5.4 on CentOS 7 and when there is a php file that throws an error (either an exception, or a syntax error) it returns an HTTP 200 status code instead of 500.
A work around to bug #50921: use auto_prepend_file to set the http response code to 500, then set it to 200 when you know the page has bootstrapped. A representative, but not comprehensive, example:
# php.ini
auto_prepend_file = /path/to/auto_prepend_file.php
# auto_prepend_file.php
If index.php
has a crashing error in it, the 500 set via auto-prepend file will still execute. There won't be any output unless display_error
and/or display_startup_error
are on, though. If bootstrap.php
or any of its dependents have crashing error, then the shutdown function will handle those.
There are still scenarios here, which need to be considered:
A lot of this depends upon how much control you have over your environment (eg, write to INI_SYSTEM level config) and how your framework operates (eg ob_start, or no).
I'll emphasize this is just a workaround. If your auto_prepend_file itself has parse errors, then you're back to square one: PHP emits a 200 status error code. Fixing the engine to emit a 500 is the only proper way to break this chicken-and-egg cycle.