Merge "Add missing return types to User::getOption()"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 23 Mar 2018 01:41:28 +0000 (01:41 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 23 Mar 2018 01:41:28 +0000 (01:41 +0000)
includes/user/User.php
tests/phpunit/includes/user/UserTest.php

index 47d7533..fda49a5 100644 (file)
@@ -3084,7 +3084,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 ca83d66..e819d35 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' ) );
        }
 
        /**