Prevent sending error status codes via error handler when headers are already sent

This commit is contained in:
Joshua Ramon Enslin 2024-09-18 17:24:07 +02:00
parent ae65868021
commit ab3150254f
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -69,7 +69,9 @@ function mdShortenerExceptionHandler(Throwable $exception):void {
$errorReporter = new MDErrorReporter("md:frontend", "bugs-frontend@museum-digital.de");
$errorCategory = MDErrorReporter::categorizeError($exception);
http_response_code(404);
if (headers_sent() === false) {
http_response_code(404);
}
switch ($errorCategory) {
case MDErrorReporter::MD_ERROR_KNOWN: