diff options
Diffstat (limited to 'src/application/mystic/forum/utils')
-rw-r--r-- | src/application/mystic/forum/utils/RequestUtils.php | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/application/mystic/forum/utils/RequestUtils.php b/src/application/mystic/forum/utils/RequestUtils.php index 796a476..11253aa 100644 --- a/src/application/mystic/forum/utils/RequestUtils.php +++ b/src/application/mystic/forum/utils/RequestUtils.php @@ -23,7 +23,7 @@ final class RequestUtils { public static function ensureRequestMethod(string $method): void { if (!self::isRequestMethod($method)) { - http_response_code(415); + http_response_code(405); Messaging::error("Invalid request method " . self::getRequestMethod()); exit; } @@ -40,9 +40,10 @@ final class RequestUtils { return $fieldValue; } - public static function storeForm(): void { + public static function storeForm(string $formId): void { $_SESSION["lastForm"] = $_POST ?? []; $_SESSION["lastForm_uri"] = $_SERVER["REQUEST_URI"]; + $_SESSION["lastForm_id"] = $formId; } public static function setFormErrorDestination(?string $dest): ?string { @@ -55,7 +56,7 @@ final class RequestUtils { $next ??= self::$formErrorDestination ?? $_SERVER["REQUEST_URI"]; $_SESSION["formError/$formId"] = $message; // store last form submission - self::storeForm(); + self::storeForm($formId); header("Location: $next"); exit; } @@ -66,14 +67,20 @@ final class RequestUtils { return $err; } - public static function getLastForm(string &$lastFormUri): ?array { + public static function getLastForm_legacy(string &$lastFormUri): ?array { $lastFormUri = $_SESSION["lastForm_uri"] ?? ""; return $_SESSION["lastForm"] ?? null; } + public static function getLastForm(string &$lastFormId): ?array { + $lastFormId = $_SESSION["lastForm_id"] ?? ""; + return $_SESSION["lastForm"] ?? null; + } + public static function clearLastForm(): void { unset($_SESSION["lastForm"]); unset($_SESSION["lastForm_uri"]); + unset($_SESSION["lastForm_id"]); } public static function getAuthorizedUser(Database &$db): ?User { |