From c13445afa9db4e859dc6d04cb23ee86874912cde Mon Sep 17 00:00:00 2001 From: Dale Davies Date: Mon, 25 Jul 2022 12:50:24 +0100 Subject: [PATCH] Close session early to avoid session lock blocking other scripts --- jumpapp/classes/API/AbstractAPI.php | 2 ++ jumpapp/classes/Pages/AbstractPage.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/jumpapp/classes/API/AbstractAPI.php b/jumpapp/classes/API/AbstractAPI.php index c30f641..cca5f7e 100644 --- a/jumpapp/classes/API/AbstractAPI.php +++ b/jumpapp/classes/API/AbstractAPI.php @@ -43,6 +43,8 @@ abstract class AbstractAPI { http_response_code(401); die(json_encode(['error' => 'API token is incorrect or missing'])); } + // Close the session as soon as possible to avoid session lock blocking other scripts. + $this->session->close(); } abstract protected function get_output(): string; diff --git a/jumpapp/classes/Pages/AbstractPage.php b/jumpapp/classes/Pages/AbstractPage.php index 4747856..5ca0770 100644 --- a/jumpapp/classes/Pages/AbstractPage.php +++ b/jumpapp/classes/Pages/AbstractPage.php @@ -45,6 +45,8 @@ abstract class AbstractPage { if (!$csrfsection->offsetExists('token')){ $csrfsection->set('token', bin2hex(random_bytes(32))); } + // Close the session as soon as possible to avoid session lock blocking other scripts. + $this->session->close(); } abstract protected function render_content(): string;