From c7a3281a73839590bfa9d8a9e73c41fc35fc2847 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 22 Dec 2023 11:03:32 +0100 Subject: Fix notifications (#5959) The notification about wrong login was not working. Noticed while working on https://github.com/FreshRSS/FreshRSS/pull/5955 This was due to timing of when the notification is retrieved. Simplified code to make the logic easier and more robust. --- lib/Minz/Request.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/Minz/Request.php') diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php index f39982be1..80d503048 100644 --- a/lib/Minz/Request.php +++ b/lib/Minz/Request.php @@ -352,8 +352,11 @@ class Minz_Request { self::setNotification('bad', $content); } - /** @return array{type:string,content:string}|null */ - public static function getNotification(): ?array { + /** + * @param $pop true (default) to remove the notification, false to keep it. + * @return array{type:string,content:string}|null + */ + public static function getNotification(bool $pop = true): ?array { $notif = null; Minz_Session::lock(); /** @var array */ @@ -365,7 +368,9 @@ class Minz_Request { $requestId = self::requestId(); if (!empty($requests[$requestId]['notification'])) { $notif = $requests[$requestId]['notification']; - unset($requests[$requestId]); + if ($pop) { + unset($requests[$requestId]); + } } Minz_Session::_param('requests', $requests); } -- cgit v1.2.3