Fix HTTP 500 on PHP < 8.2: drop standalone true union type

registerUser() declared `: string|true`; the bare `true` type requires
PHP 8.2, so including auth.php was a fatal error on PHP 8.0/8.1 — every
login/API call returned 500 while install.php (which doesn't include
auth.php) worked. Use string|bool instead. Also install a JSON exception
handler so future server errors surface a message to the SPA instead of
a blank 500.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Harwinder Sekhon
2026-07-11 11:11:30 -04:00
parent 080af984de
commit aba6ef4734
3 changed files with 16 additions and 2 deletions
+2 -1
View File
@@ -51,7 +51,8 @@ function attemptLogin(string $username, string $password): bool
return false;
}
function registerUser(string $username, string $password): string|true
/** Returns true on success, or an error-message string. */
function registerUser(string $username, string $password): string|bool
{
if (!preg_match('/^[A-Za-z0-9_.-]{3,50}$/', $username)) {
return 'Username must be 3-50 characters (letters, digits, _ . -).';