From: Alexander Ebert Date: Mon, 8 Jul 2013 17:29:25 +0000 (+0200) Subject: Locally caching default values of user options X-Git-Tag: 2.0.0_Beta_5~89 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=153648ea4d17ad71607570a57a91dceca7127475;p=GitHub%2FWoltLab%2FWCF.git Locally caching default values of user options --- diff --git a/wcfsetup/install/files/lib/data/user/UserEditor.class.php b/wcfsetup/install/files/lib/data/user/UserEditor.class.php index 265fe9f79e..34a4885ab9 100644 --- a/wcfsetup/install/files/lib/data/user/UserEditor.class.php +++ b/wcfsetup/install/files/lib/data/user/UserEditor.class.php @@ -26,6 +26,12 @@ class UserEditor extends DatabaseObjectEditor implements IEditableCachedObject { */ protected static $baseClass = 'wcf\data\user\User'; + /** + * list of user options default values + * @var array + */ + protected static $userOptionDefaultValues = null; + /** * @see wcf\data\IEditableObject::create() */ @@ -82,23 +88,25 @@ class UserEditor extends DatabaseObjectEditor implements IEditableCachedObject { * @param integer $userID */ protected static function createUserOptions($userID) { - $userOptions = array(); - // fetch default values - $sql = "SELECT optionID, defaultValue - FROM wcf".WCF_N."_user_option"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(); - while ($row = $statement->fetchArray()) { - if (!empty($row['defaultValue'])) { - $userOptions[$row['optionID']] = $row['defaultValue']; + if (self::$userOptionDefaultValues === null) { + self::$userOptionDefaultValues = array(); + + $sql = "SELECT optionID, defaultValue + FROM wcf".WCF_N."_user_option"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(); + while ($row = $statement->fetchArray()) { + if (!empty($row['defaultValue'])) { + self::$userOptionDefaultValues[$row['optionID']] = $row['defaultValue']; + } } } // insert default values $keys = $values = ''; $statementParameters = array($userID); - foreach ($userOptions as $optionID => $optionValue) { + foreach (self::$userOptionDefaultValues as $optionID => $optionValue) { $keys .= ', userOption'.$optionID; $values .= ', ?'; $statementParameters[] = $optionValue;