Remove `createNewSession` variable in SessionHandler::create()
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 1 Oct 2020 09:46:07 +0000 (11:46 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 1 Oct 2020 10:03:54 +0000 (12:03 +0200)
This always was `true` since the previous commits.

wcfsetup/install/files/lib/system/session/SessionHandler.class.php

index e50fb1a3d28524f3e9d2c370958e6e1016aea5a9..bb21b77a5d4a89e4b8e360f3e892af206df1ac13 100644 (file)
@@ -544,52 +544,49 @@ class SessionHandler extends SingletonFactory {
                
                $this->user = new User(null);
                
-               $createNewSession = true;
                $session = null;
                
-               if ($createNewSession) {
-                       // save session
-                       $sessionData = [
-                               'sessionID' => $sessionID,
-                               'userID' => $this->user->userID,
-                               'ipAddress' => UserUtil::getIpAddress(),
-                               'userAgent' => UserUtil::getUserAgent(),
-                               'lastActivityTime' => TIME_NOW,
-                               'requestURI' => UserUtil::getRequestURI(),
-                               'requestMethod' => !empty($_SERVER['REQUEST_METHOD']) ? substr($_SERVER['REQUEST_METHOD'], 0, 7) : ''
-                       ];
-                       
-                       if ($spiderID !== null) $sessionData['spiderID'] = $spiderID;
-                       
-                       try {
-                               $this->session = call_user_func([$this->sessionEditorClassName, 'create'], $sessionData);
-                       }
-                       catch (DatabaseException $e) {
-                               // MySQL error 23000 = unique key
-                               // do not check against the message itself, some weird systems localize them
-                               if ($e->getCode() == 23000) {
-                                       // find existing session
-                                       $session = call_user_func([$this->sessionClassName, 'getSessionByUserID'], $this->user->userID);
-                                       
-                                       if ($session === null) {
-                                               // MySQL reported a unique key error, but no corresponding session exists, rethrow exception
-                                               throw $e;
-                                       }
-                                       else {
-                                               // inherit existing session
-                                               $this->session = $session;
-                                               $this->loadVirtualSession(true);
-                                       }
+               // save session
+               $sessionData = [
+                       'sessionID' => $sessionID,
+                       'userID' => $this->user->userID,
+                       'ipAddress' => UserUtil::getIpAddress(),
+                       'userAgent' => UserUtil::getUserAgent(),
+                       'lastActivityTime' => TIME_NOW,
+                       'requestURI' => UserUtil::getRequestURI(),
+                       'requestMethod' => !empty($_SERVER['REQUEST_METHOD']) ? substr($_SERVER['REQUEST_METHOD'], 0, 7) : ''
+               ];
+               
+               if ($spiderID !== null) $sessionData['spiderID'] = $spiderID;
+               
+               try {
+                       $this->session = call_user_func([$this->sessionEditorClassName, 'create'], $sessionData);
+               }
+               catch (DatabaseException $e) {
+                       // MySQL error 23000 = unique key
+                       // do not check against the message itself, some weird systems localize them
+                       if ($e->getCode() == 23000) {
+                               // find existing session
+                               $session = call_user_func([$this->sessionClassName, 'getSessionByUserID'], $this->user->userID);
+                               
+                               if ($session === null) {
+                                       // MySQL reported a unique key error, but no corresponding session exists, rethrow exception
+                                       throw $e;
                                }
                                else {
-                                       // unrelated to user id
-                                       throw $e;
+                                       // inherit existing session
+                                       $this->session = $session;
+                                       $this->loadVirtualSession(true);
                                }
                        }
-                       
-                       $this->firstVisit = true;
-                       $this->loadVirtualSession(true);
+                       else {
+                               // unrelated to user id
+                               throw $e;
+                       }
                }
+               
+               $this->firstVisit = true;
+               $this->loadVirtualSession(true);
        }
        
        /**