mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-24 08:14:09 +00:00
Make lang:parseFormattedNumber more like tonumber
Users seem to expect that mw.language's parseFormattedNumber will act like tonumber when given nil or other non-string values, returning nil instead of raising an error. There's no reason not to, so we may as well. Change-Id: Ie0ff19efc84ca738e115bbd524bfd92fccf26127
This commit is contained in:
parent
ad3e5a7c48
commit
25cbfd776d
|
@ -113,7 +113,10 @@ class Scribunto_LuaLanguageLibrary extends Scribunto_LuaLibraryBase {
|
|||
if ( is_numeric( $args[0] ) ) {
|
||||
$args[0] = strval( $args[0] );
|
||||
}
|
||||
$this->checkType( $name, 1, $args[0], 'string' );
|
||||
if ( $this->getLuaType( $args[0] ) !== 'string' ) {
|
||||
// Be like tonumber(), return nil instead of erroring out
|
||||
return array( null );
|
||||
}
|
||||
return array( $lang->$name( $args[0] ) );
|
||||
|
||||
// Custom handling
|
||||
|
|
Loading…
Reference in a new issue