Fixed a storage issue
authorMarcel Werk <burntime@woltlab.com>
Tue, 1 Nov 2011 12:54:53 +0000 (13:54 +0100)
committerMarcel Werk <burntime@woltlab.com>
Tue, 1 Nov 2011 12:54:53 +0000 (13:54 +0100)
wcfsetup/install/files/lib/data/user/User.class.php

index 60e91d4a0e6ba063cd8bc2d7b6d71f0f3d920d9c..84f28d6ae737f533c7e763348a4279dff406139c 100644 (file)
@@ -125,28 +125,33 @@ class User extends DatabaseObject {
         */
        public function getLanguageIDs() {
                if ($this->languageIDs === null) {
-                       // load storage data
-                       UserStorageHandler::getInstance()->loadStorage(array($this->userID), 1);
-                       
-                       // get language ids
-                       $data = UserStorageHandler::getInstance()->getStorage(array($this->userID), 'languageIDs', 1);
-                       
-                       // cache does not exist or is outdated
-                       if ($data[$this->userID] === null) {
-                               $sql = "SELECT  languageID
-                                       FROM    wcf".WCF_N."_user_to_language
-                                       WHERE   userID = ?";
-                               $statement = WCF::getDB()->prepareStatement($sql);
-                               $statement->execute(array($this->userID));
-                               while ($row = $statement->fetchArray()) {
-                                       $this->languageIDs[] = $row['languageID'];
-                               }
-                               
-                               // update storage data
-                               UserStorageHandler::getInstance()->update($this->userID, 'languageIDs', serialize($this->languageIDs), 1);
+                       if (!$this->userID) {
+                               $this->languageIDs = array();
                        }
                        else {
-                               $this->languageIDs = unserialize($data[$this->userID]);
+                               // load storage data
+                               UserStorageHandler::getInstance()->loadStorage(array($this->userID), 1);
+                               
+                               // get language ids
+                               $data = UserStorageHandler::getInstance()->getStorage(array($this->userID), 'languageIDs', 1);
+                               
+                               // cache does not exist or is outdated
+                               if ($data[$this->userID] === null) {
+                                       $sql = "SELECT  languageID
+                                               FROM    wcf".WCF_N."_user_to_language
+                                               WHERE   userID = ?";
+                                       $statement = WCF::getDB()->prepareStatement($sql);
+                                       $statement->execute(array($this->userID));
+                                       while ($row = $statement->fetchArray()) {
+                                               $this->languageIDs[] = $row['languageID'];
+                                       }
+                                       
+                                       // update storage data
+                                       UserStorageHandler::getInstance()->update($this->userID, 'languageIDs', serialize($this->languageIDs), 1);
+                               }
+                               else {
+                                       $this->languageIDs = unserialize($data[$this->userID]);
+                               }
                        }
                }