Skip to content

Commit 5c36b54

Browse files
only show error popup when get_last_error is a real error (#305)
* only show error popup when get_last_error is a real error * Update resources/lib/UnitySite.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent c3298e7 commit 5c36b54

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

resources/lib/UnitySite.php

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -77,30 +77,32 @@ public static function shutdown()
7777
if (CONFIG["site"]["enable_shutdown_msg"] == false) {
7878
return;
7979
}
80-
if (!is_null($e = error_get_last())) {
81-
if (!headers_sent()) {
82-
self::headerResponseCode(500, "internal server error");
83-
}
84-
$errorid = uniqid();
85-
$e["unity_error_id"] = $errorid;
86-
self::errorLog("internal server error", json_encode($e));
87-
echo "
88-
<h1>An internal server error has occurred.</h1>
89-
<p>
90-
Please notify a Unity admin at "
91-
. CONFIG["mail"]["support"]
92-
. ". Error ID: $errorid.
93-
</p>
94-
";
95-
// if content already printed, status code will be ignored and alert text may not be
96-
// shown in the webpage in an obvious way, so make a popup
97-
self::alert(
98-
"An internal server error has occurred. "
99-
. "Please notify a Unity admin at "
100-
. CONFIG["mail"]["support"]
101-
. ". Error ID: $errorid."
102-
);
80+
$e = error_get_last();
81+
if (is_null($e) || $e["type"] !== E_ERROR) {
82+
return;
10383
}
84+
if (!headers_sent()) {
85+
self::headerResponseCode(500, "internal server error");
86+
}
87+
$errorid = uniqid();
88+
$e["unity_error_id"] = $errorid;
89+
self::errorLog("internal server error", json_encode($e));
90+
echo "
91+
<h1>An internal server error has occurred.</h1>
92+
<p>
93+
Please notify a Unity admin at "
94+
. CONFIG["mail"]["support"]
95+
. ". Error ID: $errorid.
96+
</p>
97+
";
98+
// if content already printed, status code will be ignored and alert text may not be
99+
// shown in the webpage in an obvious way, so make a popup
100+
self::alert(
101+
"An internal server error has occurred. "
102+
. "Please notify a Unity admin at "
103+
. CONFIG["mail"]["support"]
104+
. ". Error ID: $errorid."
105+
);
104106
}
105107

106108
public static function arrayGetOrBadRequest(array $array, ...$keys)

0 commit comments

Comments
 (0)