A free, self-hostable news aggregator…
Fix notifications (#5959)
Alexandre Alapetitec7a3281a7383
diff --git a/app/Controllers/authController.php b/app/Controllers/authController.phpindex ac3fcb0be..82dfefddd 100644--- a/app/Controllers/authController.php+++ b/app/Controllers/authController.php@@ -182,7 +182,6 @@ class FreshRSS_auth_Controller extends FreshRSS_ActionController {Minz_Request::good(_t('feedback.auth.login.success'), $url);} else {Minz_Log::warning("Password mismatch for user={$username}, nonce={$nonce}, c={$challenge}");-header('HTTP/1.1 403 Forbidden');Minz_Session::_param('POST_to_GET', true); //Prevent infinite internal redirectMinz_Request::setBadNotification(_t('feedback.auth.login.invalid'));diff --git a/app/FreshRSS.php b/app/FreshRSS.phpindex 264d8ff1a..c31655aa0 100644--- a/app/FreshRSS.php+++ b/app/FreshRSS.php@@ -16,7 +16,6 @@ class FreshRSS extends Minz_FrontController {* - Init i18n (need context)* - Init sharing system (need user conf and i18n)* - Init generic styles and scripts (need user conf)- * - Init notifications* - Enable user extensions (need all the other initializations)*/public function init(): void {@@ -58,7 +57,6 @@ class FreshRSS extends Minz_FrontController {// Complete initialization of the other FreshRSS / Minz components.self::initI18n();- self::loadNotifications();// Enable extensions for the current (logged) user.if (FreshRSS_Auth::hasAccess() || FreshRSS_Context::systemConf()->allow_anonymous) {$ext_list = FreshRSS_Context::userConf()->extensions_enabled;@@ -151,13 +149,6 @@ class FreshRSS extends Minz_FrontController {FreshRSS_View::prependScript(Minz_Url::display('/scripts/main.js?' . @filemtime(PUBLIC_PATH . '/scripts/main.js')));}- private static function loadNotifications(): void {- $notif = Minz_Request::getNotification();- if (!empty($notif)) {- FreshRSS_View::_param('notification', $notif);- }- }-public static function preLayout(): void {header("X-Content-Type-Options: nosniff");diff --git a/app/Models/View.php b/app/Models/View.phpindex 8346b3ce8..9c601b1d1 100644--- a/app/Models/View.php+++ b/app/Models/View.php@@ -27,8 +27,6 @@ class FreshRSS_View extends Minz_View {public array $tagsForEntry;/** @var array<string,array<string>> */public array $tagsForEntries;- /** @var array<string,string> */- public array $notification;public bool $excludeMutedFeeds;// Substriptionsdiff --git a/app/layout/layout.phtml b/app/layout/layout.phtmlindex adbd52327..ba6dc4a96 100644--- a/app/layout/layout.phtml+++ b/app/layout/layout.phtml@@ -77,10 +77,10 @@ if (_t('gen.dir') === 'rtl') {<?php$msg = '';$status = 'closed';- if (!empty($this->notification)) {- $msg = $this->notification['content'];- $status = $this->notification['type'];-+ $notif = Minz_Request::getNotification();+ if (!empty($notif)) {+ $msg = $notif['content'];+ $status = $notif['type'];invalidateHttpCache();}?>diff --git a/app/layout/simple.phtml b/app/layout/simple.phtmlindex f2e6bbd25..065b69fb9 100644--- a/app/layout/simple.phtml+++ b/app/layout/simple.phtml@@ -59,9 +59,10 @@<?php$msg = '';$status = 'closed';- if (!empty($this->notification)) {- $msg = $this->notification['content'];- $status = $this->notification['type'];+ $notif = Minz_Request::getNotification();+ if (!empty($notif)) {+ $msg = $notif['content'];+ $status = $notif['type'];invalidateHttpCache();}?>diff --git a/lib/Minz/Request.php b/lib/Minz/Request.phpindex 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<string,array{time:int,notification:array{type:string,content:string}}> */@@ -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);}