diff --git a/api/ticket_dependencies.php b/api/ticket_dependencies.php index 3c58e87..f75b3d5 100644 --- a/api/ticket_dependencies.php +++ b/api/ticket_dependencies.php @@ -27,10 +27,19 @@ register_shutdown_function(function () { ini_set('display_errors', 0); error_reporting(E_ALL); -// Custom error handler +// Custom error handler. Only genuine errors abort the request; notices, +// warnings and deprecations (e.g. new deprecations on a PHP upgrade) are +// logged but must not take the endpoint down with a 500. set_error_handler(function ($errno, $errstr, $errfile, $errline) { - // Log detailed error server-side + // Respect the @-operator / error_reporting. + if (!(error_reporting() & $errno)) { + return false; + } error_log("PHP Error in ticket_dependencies.php: $errstr in $errfile:$errline"); + if (!in_array($errno, [E_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR, E_PARSE], true)) { + // Non-fatal: log and continue. + return true; + } ob_end_clean(); http_response_code(500); header('Content-Type: application/json'); diff --git a/helpers/Database.php b/helpers/Database.php index b6d2f7a..1f8c5d9 100644 --- a/helpers/Database.php +++ b/helpers/Database.php @@ -22,11 +22,9 @@ class Database self::$connection = self::createConnection(); } - // Check if connection is still alive - if (!self::$connection->ping()) { - self::$connection = self::createConnection(); - } - + // Note: no ping()/reconnect check — mysqli auto-reconnect was removed in + // PHP 8.2 and mysqli::ping() is deprecated in 8.4. The connection is + // request-scoped and short-lived, so a liveness check is unnecessary. return self::$connection; }