User::saveOptions() optimization
[lhc/web/wiklou.git] / includes / User.php
index ca3f79b..7f7a22d 100644 (file)
@@ -4629,20 +4629,20 @@ class User {
                        return;
                }
 
+               $defaultOptions = self::getDefaultOptions();
+
                $userId = $this->getId();
                $insert_rows = array();
-               foreach ( $saveOptions as $key => $value ) {
-                       // Don't bother storing default values
-                       $defaultOption = self::getDefaultOption( $key );
-                       if ( ( is_null( $defaultOption ) &&
-                                       !( $value === false || is_null( $value ) ) ) ||
-                                       $value != $defaultOption ) {
-                               $insert_rows[] = array(
-                                               'up_user' => $userId,
-                                               'up_property' => $key,
-                                               'up_value' => $value,
-                                       );
+               $changedOptions = array_diff_assoc( $saveOptions, $defaultOptions );
+               foreach ( $changedOptions as $key => $value ) {
+                       if ( $value === false || is_null( $value ) ) {
+                               continue;
                        }
+                       $insert_rows[] = array(
+                               'up_user' => $userId,
+                               'up_property' => $key,
+                               'up_value' => $value,
+                       );
                }
 
                $dbw = wfGetDB( DB_MASTER );