Skip to content

Commit 5f9d48c

Browse files
committed
use html_errors ini setting instead of php_sapi_name
1 parent c2976de commit 5f9d48c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

resources/lib/UnityHTTPD.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,12 @@ public static function errorID(?\Throwable $e = null): string
6767

6868
/*
6969
generates a unique error ID, writes to error log, and then:
70-
if PHP is being run in the CLI:
70+
if "html_errors" is disabled in the PHP config file:
7171
prints a message to stdout and dies
7272
else, if the user is doing an HTTP POST:
7373
registers a message in the user's session and issues a redirect to display that message
7474
else:
7575
prints an HTML message to stdout, sets an HTTP response code, and dies
76-
we don't want HTML formatted output in the CLI
7776
we can't always do a redirect or else we could risk an infinite loop.
7877
*/
7978
public static function gracefulDie(
@@ -97,7 +96,7 @@ public static function gracefulDie(
9796
$user_message_body .= " $suffix";
9897
}
9998
self::errorLog($log_title, $log_message, data: $data, error: $error, errorid: $errorid);
100-
if (php_sapi_name() == "cli") {
99+
if (!ini_get("html_errors")) {
101100
self::die("$user_message_title -- $user_message_body");
102101
} elseif (($_SERVER["REQUEST_METHOD"] ?? "") == "POST") {
103102
self::messageError($user_message_title, $user_message_body);
@@ -109,7 +108,8 @@ public static function gracefulDie(
109108
// text may not be shown in the webpage in an obvious way, so make a popup
110109
self::alert("$user_message_title -- $user_message_body");
111110
echo "<h1>$user_message_title</h1><p>$user_message_body</p>";
112-
if (!is_null($error) && ini_get("display_errors") && ini_get("html_errors")) {
111+
// display_errors should not be enabled in production
112+
if (!is_null($error) && ini_get("display_errors")) {
113113
echo "<table>";
114114
echo $error->xdebug_message;
115115
echo "</table>";

0 commit comments

Comments
 (0)