From 0319cc9d234e107109d988f36f2361b25f9f0777 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 6 Oct 2020 23:19:45 +0200 Subject: Minz allow parallel sessions (#3096) * Minz allow parallel sessions #fix https://github.com/FreshRSS/FreshRSS/issues/3093 * Array optimisation * Array optimisation missing * Reduce direct access to $_SESSION except in install process * Fix session start headers warning * Use cookie only the first time the session is started: `PHP Warning: session_start(): Cannot start session when headers already sent in /var/www/FreshRSS/lib/Minz/Session.php on line 39` * New concept of volatile session for API calls Optimisation: do not use cookies or local storage at all for API calls without a Web session Fix warning: ``` PHP Warning: session_destroy(): Trying to destroy uninitialized session in Unknown on line 0 ``` * Only call Minz_Session::init once in our index It was called twice (once indirectly via FreshRSS->init()) * Whitespace * Mutex for notifications Implement mutex for notifications https://github.com/FreshRSS/FreshRSS/pull/3208#discussion_r499509809 * Typo * Install script is not ready for using Minz_Session --- p/api/fever.php | 4 +--- p/api/greader.php | 4 +--- p/i/index.php | 5 +++-- 3 files changed, 5 insertions(+), 8 deletions(-) (limited to 'p') diff --git a/p/api/fever.php b/p/api/fever.php index 909e29d32..64e6dfd65 100644 --- a/p/api/fever.php +++ b/p/api/fever.php @@ -25,9 +25,7 @@ if (!FreshRSS_Context::$system_conf->api_enabled) { die('Service Unavailable!'); } -ini_set('session.use_cookies', '0'); -register_shutdown_function('session_destroy'); -Minz_Session::init('FreshRSS'); +Minz_Session::init('FreshRSS', true); // ================================================================================================ // diff --git a/p/api/greader.php b/p/api/greader.php index 027662cc1..e93585275 100644 --- a/p/api/greader.php +++ b/p/api/greader.php @@ -935,9 +935,7 @@ if (!FreshRSS_Context::$system_conf->api_enabled) { checkCompatibility(); } -ini_set('session.use_cookies', '0'); -register_shutdown_function('session_destroy'); -Minz_Session::init('FreshRSS'); +Minz_Session::init('FreshRSS', true); $user = $pathInfos[1] === 'accounts' ? '' : authorizationToUser(); FreshRSS_Context::$user_conf = null; diff --git a/p/i/index.php b/p/i/index.php index 35e53ec5e..d1d56bbb9 100755 --- a/p/i/index.php +++ b/p/i/index.php @@ -27,8 +27,6 @@ if (file_exists(DATA_PATH . '/do-install.txt')) { require(APP_PATH . '/install.php'); } else { session_cache_limiter(''); - Minz_Session::init('FreshRSS'); - Minz_Session::_param('keepAlive', 1); //To prevent the PHP session from expiring if (!file_exists(DATA_PATH . '/no-cache.txt')) { require(LIB_PATH . '/http-conditional.php'); @@ -38,6 +36,8 @@ if (file_exists(DATA_PATH . '/do-install.txt')) { @filemtime(join_path(DATA_PATH, 'config.php')) ); if (httpConditional($dateLastModification, 0, 0, false, PHP_COMPRESSION, true)) { + Minz_Session::init('FreshRSS'); + Minz_Session::_param('keepAlive', 1); //To prevent the PHP session from expiring exit(); //No need to send anything } } @@ -65,6 +65,7 @@ if (file_exists(DATA_PATH . '/do-install.txt')) { if ($result === true) { $front_controller = new FreshRSS(); $front_controller->init(); + Minz_Session::_param('keepAlive', 1); //To prevent the PHP session from expiring $front_controller->run(); } else { $error = $result; -- cgit v1.2.3