Use User::getDefaultOption() instead of $wgDefaultUserOptions
authorumherirrender <umherirrender_de.wp@web.de>
Sat, 16 Jun 2012 08:16:28 +0000 (10:16 +0200)
committerAaron Schulz <aschulz@wikimedia.org>
Sat, 21 Jul 2012 10:00:04 +0000 (03:00 -0700)
Using User::getDefaultOption() in User::setOption() sets preferences like
'language' to the right default value, whereas using $wgDefaultOptions
sets the language to null because language is not part of $wgDefaultUserOptions,
but it is part of return value of User::getDefaultOption().

This only makes problems when reusing the same user object, because when
a new user object is created, the value of 'language' is correct.

Change-Id: I43a32c66fc3997a4f842c63af374e84d234602b2

includes/User.php

index 5fc0773..3279a38 100644 (file)
@@ -2288,9 +2288,11 @@ class User {
                $this->loadOptions();
 
                // Explicitly NULL values should refer to defaults
-               global $wgDefaultUserOptions;
-               if( is_null( $val ) && isset( $wgDefaultUserOptions[$oname] ) ) {
-                       $val = $wgDefaultUserOptions[$oname];
+               if( is_null( $val ) ) {
+                       $defaultOption = self::getDefaultOption( $oname );
+                       if( !is_null( $defaultOption ) ) {
+                               $val = $defaultOption;
+                       }
                }
 
                $this->mOptions[$oname] = $val;