Anomie has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/71820


Change subject: Make lang:parseFormatterNumber more like tonumber
......................................................................

Make lang:parseFormatterNumber more like tonumber

Users seem to expect that mw.language's parseFormatterNumber 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
---
M engines/LuaCommon/LanguageLibrary.php
1 file changed, 4 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Scribunto 
refs/changes/20/71820/1

diff --git a/engines/LuaCommon/LanguageLibrary.php 
b/engines/LuaCommon/LanguageLibrary.php
index 2a6d1de..68a958c 100644
--- a/engines/LuaCommon/LanguageLibrary.php
+++ b/engines/LuaCommon/LanguageLibrary.php
@@ -113,7 +113,10 @@
                                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

-- 
To view, visit https://gerrit.wikimedia.org/r/71820
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie0ff19efc84ca738e115bbd524bfd92fccf26127
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Scribunto
Gerrit-Branch: master
Gerrit-Owner: Anomie <bjor...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to