From: Sam Wilson Date: Fri, 23 Mar 2018 01:14:41 +0000 (+0800) Subject: Add missing return types to User::getOption() X-Git-Tag: 1.31.0-rc.0~305^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=12b3176d4f29be472b824c00b23f1e568b1d3050 Add missing return types to User::getOption() String zeros are converted to ints, and email-blacklist returns an array of integers. Change-Id: I2ac2a4e8effd4816e9c1e835b86241c7fe850605 --- diff --git a/includes/user/User.php b/includes/user/User.php index d6523a7f3c..2effcdecbd 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -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() */ diff --git a/tests/phpunit/includes/user/UserTest.php b/tests/phpunit/includes/user/UserTest.php index c225ba5b8c..84ca07007b 100644 --- a/tests/phpunit/includes/user/UserTest.php +++ b/tests/phpunit/includes/user/UserTest.php @@ -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' ) ); } /**