From b422805af4d72daead41fdc4851d119d413df49a Mon Sep 17 00:00:00 2001 From: Jay Trees Date: Sat, 11 May 2024 18:31:43 +0200 Subject: [PATCH] fix: load user session when database is available --- index.php | 6 +++++- src/classes/wishthis/User.php | 12 ++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/index.php b/index.php index ef062bfa..99336dd5 100644 --- a/index.php +++ b/index.php @@ -54,7 +54,6 @@ session_start( ); $user = User::getCurrent(); -$user->loadFromSession(); /** * Database @@ -80,6 +79,11 @@ if ( * Options */ $options = new Options($database); + + /** + * User session + */ + $user->loadFromSession(); } /** diff --git a/src/classes/wishthis/User.php b/src/classes/wishthis/User.php index e9f67eab..0ec86bd8 100644 --- a/src/classes/wishthis/User.php +++ b/src/classes/wishthis/User.php @@ -259,12 +259,12 @@ class User return false; } - $database = new Database( - DATABASE_HOST, - DATABASE_NAME, - DATABASE_USER, - DATABASE_PASSWORD - ); + global $database; + + if (false === $database) { + return false; + } + $database->connect(); $sessions = $database