current revision.
* (bug 41494) Honor $wgLogExceptionBacktrace when logging non-API exceptions
caught during API execution.
+* (bug 37963) Fixed loading process for user options
=== API changes in 1.21 ===
* prop=revisions can now report the contentmodel and contentformat, see docs/contenthandler.txt
global $wgHiddenPrefs;
$this->loadOptions();
- if ( is_null( $this->mOptions ) ) {
- if($defaultOverride != '') {
- return $defaultOverride;
- }
- $this->mOptions = User::getDefaultOptions();
- }
-
# We want 'disabled' preferences to always behave as the default value for
# users, even if they have set the option explicitly in their settings (ie they
# set it, and then it was disabled removing their ability to change it). But
* @param $val mixed New value to set
*/
public function setOption( $oname, $val ) {
- $this->load();
$this->loadOptions();
// Explicitly NULL values should refer to defaults
if( is_null( $val ) ) {
- $defaultOption = self::getDefaultOption( $oname );
- if( !is_null( $defaultOption ) ) {
- $val = $defaultOption;
- }
+ $val = self::getDefaultOption( $oname );
}
$this->mOptions[$oname] = $val;
$user->clearInstanceCache();
$this->assertEquals( 4, $user->getEditCount(), 'After increasing the edit count manually, the user edit count should be 4' );
}
+
+ /**
+ * Test changing user options.
+ */
+ public function testOptions() {
+ $user = User::newFromName( 'UnitTestUser' );
+ $user->addToDatabase();
+
+ $user->setOption( 'someoption', 'test' );
+ $user->setOption( 'cols', 200 );
+ $user->saveSettings();
+
+ $user = User::newFromName( 'UnitTestUser' );
+ $this->assertEquals( 'test', $user->getOption( 'someoption' ) );
+ $this->assertEquals( 200, $user->getOption( 'cols' ) );
+ }
+
+ /**
+ * Bug 37963
+ * Make sure defaults are loaded when setOption is called.
+ */
+ public function testAnonOptions() {
+ global $wgDefaultUserOptions;
+ $this->user->setOption( 'someoption', 'test' );
+ $this->assertEquals( $wgDefaultUserOptions['cols'], $this->user->getOption( 'cols' ) );
+ $this->assertEquals( 'test', $this->user->getOption( 'someoption' ) );
+ }
}