1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-13 18:24:57 +02:00

Fix issue where WireShutdown in fatal error state didn't use http 500 header when debug mode was on

This commit is contained in:
Ryan Cramer
2020-04-03 09:13:14 -04:00
parent 1c68448267
commit d3bbf6577e

View File

@@ -291,6 +291,22 @@ class WireShutdown extends Wire {
return $message;
}
/**
* Send fatal error http header and return error code sent
*
* @return int
*
*/
protected function sendFatalHeader() {
include_once(dirname(__FILE__) . '/WireHttp.php');
$http = new WireHttp();
$codes = $http->getHttpCodes();
$code = (int) ($this->config ? $this->config->fatalErrorCode : 500);
if(!isset($codes[$code])) $code = 500;
header("HTTP/1.1 $code " . $codes[$code]);
return $code;
}
/**
* Send a 500 internal server error
*
@@ -302,14 +318,8 @@ class WireShutdown extends Wire {
*/
protected function sendFatalError($message, $useHTML) {
include_once(dirname(__FILE__) . '/WireHttp.php');
$http = new WireHttp();
$codes = $http->getHttpCodes();
$code = (int) $this->config ? $this->config->fatalErrorCode : 500;
if(!isset($codes[$code])) $code = 500;
if($useHTML) {
header("HTTP/1.1 $code " . $codes[$code]);
$code = $this->sendFatalHeader();
$message = htmlspecialchars($message, ENT_QUOTES, 'UTF-8');
// file that error message will be output in, when available
$path = $this->config->paths->templates;
@@ -484,6 +494,7 @@ class WireShutdown extends Wire {
if($why) {
$why = $this->labels['shown-because'] . " $why $who";
$message = $this->amendErrorMessage($message);
$this->sendFatalHeader();
$this->sendErrorMessage($message, $why, $useHTML);
} else {
$this->sendFatalError($who, $useHTML);