openrat-cms

OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs | README

commit 5f4cace17bd4b5ffc76e057fabb0814a9cd89472
parent c799165fa6db27f4d3ff47a75046eefcfe0616ec
Author: Jan Dankert <develop@jandankert.de>
Date:   Thu, 19 Nov 2020 23:27:20 +0100

Fix: Updating database was partially broken.

Diffstat:
Mmodules/cms/Dispatcher.class.php | 11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/modules/cms/Dispatcher.class.php b/modules/cms/Dispatcher.class.php @@ -402,8 +402,6 @@ class Dispatcher if ( ! $enabledDbids ) throw new UIException(Messages::DATABASE_CONNECTION_ERROR, 'No database configured.',new DatabaseException('No database configured' ) ); - $firstDbContact = ! Session::getDatabaseId(); - $possibleDbIds = []; if ( $this->request->hasRequestVar('dbid') ) @@ -431,16 +429,19 @@ class Dispatcher $db = new Database( $dbConfig->merge( $dbConfig->subset($key))->getConfig() ); $db->id = $dbid; - Session::setDatabaseId( $dbid ); - Session::setDatabase ( $db ); } catch(\Exception $e) { throw new UIException(Messages::DATABASE_CONNECTION_ERROR, "Could not connect to DB ".$dbid, $e); } + // Is this the first time we are connected to this database in this session? + $firstDbContact = Session::getDatabaseId() != $dbid; + + Session::setDatabaseId( $dbid ); + Session::setDatabase ( $db ); if ( $firstDbContact ) - // Test, if we should update the database scheme. + // Test, if we must install/update the database scheme. $this->updateDatabase( $dbid ); return;