https://bugzilla.wikimedia.org/show_bug.cgi?id=37963

       Web browser: ---
             Bug #: 37963
           Summary: Calling User::getOption after User::setOption will
                    return null instead of default values for an option if
                    it isn't set
           Product: MediaWiki
           Version: 1.20-git
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: Unprioritized
         Component: User preferences
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]
    Classification: Unclassified
   Mobile Platform: ---


Assuming the following:
 $user = new User;
 $user->setOption( 'someoption' );
 $user->getOption( 'someotheroption' );

the getOption will return null even though it is set in default options. When
calling
 $user->getOption( 'someotheroption' );
 $user->setOption( 'someoption' );
instead, it will work perfectly fine.

This is because User::getOption() will check whether User::mOptions is set to
null and in this case get the default options. It is not null anymore after
setOption() though.
Therefore, the default options should be loaded in the constructor I guess.
Might be that this is more expensive though. There could be a more complex
solution to this, perhaps checking in setOption() whether options are null and
then setting some internal member to check against in getOption()

-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.

_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to