*/
protected static $baseClass = 'wcf\data\user\User';
+ /**
+ * list of user options default values
+ * @var array
+ */
+ protected static $userOptionDefaultValues = null;
+
/**
* @see wcf\data\IEditableObject::create()
*/
* @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;