Add missing return types to User::getOption()
authorSam Wilson <sam@samwilson.id.au>
Fri, 23 Mar 2018 01:14:41 +0000 (09:14 +0800)
committerSam Wilson <sam@samwilson.id.au>
Fri, 23 Mar 2018 01:14:41 +0000 (09:14 +0800)
String zeros are converted to ints, and email-blacklist returns
an array of integers.

Change-Id: I2ac2a4e8effd4816e9c1e835b86241c7fe850605

includes/user/User.php
tests/phpunit/includes/user/UserTest.php

index d6523a7..2effcde 100644 (file)
@@ -3082,7 +3082,7 @@ class User implements IDBAccessObject, UserIdentity {
         * @param string $oname The option to check
         * @param string $defaultOverride A default value returned if the option does not exist
         * @param bool $ignoreHidden Whether to ignore the effects of $wgHiddenPrefs
-        * @return string|null User's current value for the option
+        * @return string|array|int|null User's current value for the option
         * @see getBoolOption()
         * @see getIntOption()
         */
index c225ba5..84ca070 100644 (file)
@@ -350,6 +350,7 @@ class UserTest extends MediaWikiTestCase {
 
                $user->setOption( 'userjs-someoption', 'test' );
                $user->setOption( 'rclimit', 200 );
+               $user->setOption( 'wpwatchlistdays', '0' );
                $user->saveSettings();
 
                $user = User::newFromName( $user->getName() );
@@ -361,6 +362,11 @@ class UserTest extends MediaWikiTestCase {
                MediaWikiServices::getInstance()->getMainWANObjectCache()->clearProcessCache();
                $this->assertEquals( 'test', $user->getOption( 'userjs-someoption' ) );
                $this->assertEquals( 200, $user->getOption( 'rclimit' ) );
+
+               // Check that an option saved as a string '0' is returned as an integer.
+               $user = User::newFromName( $user->getName() );
+               $user->load( User::READ_LATEST );
+               $this->assertSame( 0, $user->getOption( 'wpwatchlistdays' ) );
        }
 
        /**