From f37d4742ff52440f540321b5d19220fa8d46f292 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Tue, 1 Nov 2011 13:54:53 +0100 Subject: [PATCH] Fixed a storage issue --- .../files/lib/data/user/User.class.php | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/wcfsetup/install/files/lib/data/user/User.class.php b/wcfsetup/install/files/lib/data/user/User.class.php index 60e91d4a0e..84f28d6ae7 100644 --- a/wcfsetup/install/files/lib/data/user/User.class.php +++ b/wcfsetup/install/files/lib/data/user/User.class.php @@ -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]); + } } } -- 2.20.1