Properly resolve conflicting UNIQUE KEY in virtual sessions
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 2 Dec 2014 01:23:00 +0000 (02:23 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 2 Dec 2014 01:45:59 +0000 (02:45 +0100)
wcfsetup/install/files/lib/system/session/SessionHandler.class.php

index 37401761da266a0fc2ba36e1e37e838cc790dfab..c58ea088dcfaeda5bdd4e67b19c5a9454e38ff8e 100644 (file)
@@ -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