From 7a1eb67db21d2094ac6b044e9842adaceeb58af9 Mon Sep 17 00:00:00 2001 From: vibpe <79282744+vibpe@users.noreply.github.com> Date: Fri, 20 Nov 2026 14:56:53 +0100 Subject: [PATCH] Send the 419 status with a reason phrase so Apache does not answer 500 (#1209) Fixes #1208 - add reason phrase with http 419 response (used with invalid or missing CSRF token is answered with the "Session expired"), otherwise Apache returns a http 500 response instead. thanks @vibpe --- public/common.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/public/common.php b/public/common.php index a00f0b09..bece773b 100644 --- a/public/common.php +++ b/public/common.php @@ -6,7 +6,10 @@ set_exception_handler(function ($exception) { // we could do something much better here - e.g. if the user is logged in, and an admin, show a full stack trace etc. if ($exception instanceof CsrfInvalidException) { - http_response_code(419); // HTTP 419 Page Expired. + // 419 is not a registered status code: without an explicit reason phrase + // Apache replaces the status line with "500 Internal Server Error". + // Always HTTP/1.1: mod_php only applies a status line starting with "HTTP/1.". + header('HTTP/1.1 419 Page Expired', true, 419); $title = Config::lang('session_expired_title') ?: 'Session expired'; $message = Config::lang('session_expired_message') ?: 'The page token is no longer valid. Please return and try again.'; $button = Config::lang('session_expired_button') ?: 'Continue';