Initialize LegacySession with `null`
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 9 Aug 2022 07:43:52 +0000 (09:43 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 9 Aug 2022 07:44:42 +0000 (09:44 +0200)
Otherwise ACP will access an uninitialized property during shutdown.

see 0867fa82fd1faaf2e1e9192102cae97a9759df70

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

index 39bfd403d121ec19cf21216d3824642d1d00e395..3259c9983466e87a4003225aae4d534000b31b82 100644 (file)
@@ -74,7 +74,7 @@ final class SessionHandler extends SingletonFactory
      */
     private string $sessionID;
 
-    protected ?LegacySession $legacySession;
+    protected ?LegacySession $legacySession = null;
 
     /**
      * user object
@@ -589,7 +589,7 @@ final class SessionHandler extends SingletonFactory
             $legacySessionStatement->execute($condition->getParameters());
             $this->legacySession = $legacySessionStatement->fetchSingleObject(LegacySession::class);
 
-            if (!$this->legacySession) {
+            if ($this->legacySession === null) {
                 try {
                     $this->legacySession = $this->createLegacySession();
                 } catch (DatabaseQueryExecutionException $e) {
@@ -666,7 +666,7 @@ final class SessionHandler extends SingletonFactory
                 $this->legacySession = $statement->fetchSingleObject(LegacySession::class);
             }
 
-            if (!$this->legacySession) {
+            if ($this->legacySession === null) {
                 $this->legacySession = $this->createLegacySession();
             }
         }
@@ -1159,7 +1159,7 @@ final class SessionHandler extends SingletonFactory
             }
         }
 
-        if ($this->legacySession) {
+        if ($this->legacySession !== null) {
             $sessionEditor = new SessionEditor($this->legacySession);
             $sessionEditor->update($data);
         }