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 --- app/Models/DatabaseDAO.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'app/Models/DatabaseDAO.php') diff --git a/app/Models/DatabaseDAO.php b/app/Models/DatabaseDAO.php index 2e0ee25a0..9d762a615 100644 --- a/app/Models/DatabaseDAO.php +++ b/app/Models/DatabaseDAO.php @@ -20,11 +20,10 @@ class FreshRSS_DatabaseDAO extends Minz_ModelPdo { try { $sql = sprintf($SQL_CREATE_DB, empty($db['base']) ? '' : $db['base']); - return $this->pdo->exec($sql) !== false; + return $this->pdo->exec($sql) === false ? 'Error during CREATE DATABASE' : ''; } catch (Exception $e) { - $_SESSION['bd_error'] = $e->getMessage(); - syslog(LOG_DEBUG, __method__ . ' warning: ' . $e->getMessage()); - return false; + syslog(LOG_DEBUG, __method__ . ' notice: ' . $e->getMessage()); + return $e->getMessage(); } } @@ -33,11 +32,10 @@ class FreshRSS_DatabaseDAO extends Minz_ModelPdo { $sql = 'SELECT 1'; $stm = $this->pdo->query($sql); $res = $stm->fetchAll(PDO::FETCH_COLUMN, 0); - return $res != false; + return $res == false ? 'Error during SQL connection test!' : ''; } catch (Exception $e) { - $_SESSION['bd_error'] = $e->getMessage(); syslog(LOG_DEBUG, __method__ . ' warning: ' . $e->getMessage()); - return false; + return $e->getMessage(); } } -- cgit v1.2.3