From 796d4f145b8e6b2bfc1acb86dcfefc3d98f92c9a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 2 Dec 2014 02:23:00 +0100 Subject: [PATCH] Properly resolve conflicting UNIQUE KEY in virtual sessions --- .../lib/system/session/SessionHandler.class.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php index 37401761da..c58ea088dc 100644 --- a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php +++ b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php @@ -738,14 +738,12 @@ class SessionHandler extends SingletonFactory { // MySQL error 23000 = unique key // do not check against the message itself, some weird systems localize them if ($e->getCode() == 23000) { - // find existing session for this user - $session = call_user_func(array($this->sessionClassName, 'getSessionByUserID'), $user->userID); - - // update session + // delete guest session $sessionEditor = new $this->sessionEditorClassName($this->session); - $sessionEditor->update(array( - 'userID' => $user->userID - )); + $sessionEditor->delete(); + + // inherit existing session + $this->session = $session; } else { // not our business -- 2.20.1