Revert "Parser functions now format numbers according to page language"
authorLegoktm <legoktm.wikipedia@gmail.com>
Wed, 2 Nov 2016 20:22:32 +0000 (20:22 +0000)
committerLegoktm <legoktm.wikipedia@gmail.com>
Wed, 2 Nov 2016 20:23:18 +0000 (20:23 +0000)
This reverts commit 4290f686c07265d40718fc3358f196de41bbde57.

Bug: T149840
Change-Id: I7e2dfe14813b510a1a974ae0007390bb2879f804

RELEASE-NOTES-1.28
includes/parser/CoreParserFunctions.php

index a2a986f..4e445a5 100644 (file)
@@ -223,8 +223,6 @@ changes to languages because of Phabricator reports.
   Instead of --keep-uploads, use the same option to parserTests.php, but you
   must specify a directory with --upload-dir.
 * The 'jquery.arrowSteps' ResourceLoader module is now deprecated.
   Instead of --keep-uploads, use the same option to parserTests.php, but you
   must specify a directory with --upload-dir.
 * The 'jquery.arrowSteps' ResourceLoader module is now deprecated.
-* (T62604) Core parser functions returning a number now format the number according
-  to the page content language, not wiki content language.
 * IP::isConfiguredProxy() and IP::isTrustedProxy() were removed. Callers should
   migrate to using the same functions on a ProxyLookup instance, obtainable from
   MediaWikiServices.
 * IP::isConfiguredProxy() and IP::isTrustedProxy() were removed. Callers should
   migrate to using the same functions on a ProxyLookup instance, obtainable from
   MediaWikiServices.
index ef26db6..01cce02 100644 (file)
@@ -487,58 +487,40 @@ class CoreParserFunctions {
                return $mwObject->matchStartToEnd( $value );
        }
 
                return $mwObject->matchStartToEnd( $value );
        }
 
-       public static function formatRaw( $num, $raw, Language $language ) {
+       public static function formatRaw( $num, $raw ) {
                if ( self::matchAgainstMagicword( 'rawsuffix', $raw ) ) {
                        return $num;
                } else {
                if ( self::matchAgainstMagicword( 'rawsuffix', $raw ) ) {
                        return $num;
                } else {
-                       return $language->formatNum( $num );
+                       global $wgContLang;
+                       return $wgContLang->formatNum( $num );
                }
        }
                }
        }
-
        public static function numberofpages( $parser, $raw = null ) {
        public static function numberofpages( $parser, $raw = null ) {
-               return self::formatRaw( SiteStats::pages(), $raw, $parser->getFunctionLang() );
+               return self::formatRaw( SiteStats::pages(), $raw );
        }
        }
-
        public static function numberofusers( $parser, $raw = null ) {
        public static function numberofusers( $parser, $raw = null ) {
-               return self::formatRaw( SiteStats::users(), $raw, $parser->getFunctionLang() );
+               return self::formatRaw( SiteStats::users(), $raw );
        }
        public static function numberofactiveusers( $parser, $raw = null ) {
        }
        public static function numberofactiveusers( $parser, $raw = null ) {
-               return self::formatRaw( SiteStats::activeUsers(), $raw, $parser->getFunctionLang() );
+               return self::formatRaw( SiteStats::activeUsers(), $raw );
        }
        }
-
        public static function numberofarticles( $parser, $raw = null ) {
        public static function numberofarticles( $parser, $raw = null ) {
-               return self::formatRaw( SiteStats::articles(), $raw, $parser->getFunctionLang() );
+               return self::formatRaw( SiteStats::articles(), $raw );
        }
        }
-
        public static function numberoffiles( $parser, $raw = null ) {
        public static function numberoffiles( $parser, $raw = null ) {
-               return self::formatRaw( SiteStats::images(), $raw, $parser->getFunctionLang() );
+               return self::formatRaw( SiteStats::images(), $raw );
        }
        }
-
        public static function numberofadmins( $parser, $raw = null ) {
        public static function numberofadmins( $parser, $raw = null ) {
-               return self::formatRaw(
-                       SiteStats::numberingroup( 'sysop' ),
-                       $raw,
-                       $parser->getFunctionLang()
-               );
+               return self::formatRaw( SiteStats::numberingroup( 'sysop' ), $raw );
        }
        }
-
        public static function numberofedits( $parser, $raw = null ) {
        public static function numberofedits( $parser, $raw = null ) {
-               return self::formatRaw( SiteStats::edits(), $raw, $parser->getFunctionLang() );
+               return self::formatRaw( SiteStats::edits(), $raw );
        }
        }
-
        public static function pagesinnamespace( $parser, $namespace = 0, $raw = null ) {
        public static function pagesinnamespace( $parser, $namespace = 0, $raw = null ) {
-               return self::formatRaw(
-                       SiteStats::pagesInNs( intval( $namespace ) ),
-                       $raw,
-                       $parser->getFunctionLang()
-               );
+               return self::formatRaw( SiteStats::pagesInNs( intval( $namespace ) ), $raw );
        }
        public static function numberingroup( $parser, $name = '', $raw = null ) {
        }
        public static function numberingroup( $parser, $name = '', $raw = null ) {
-               return self::formatRaw(
-                       SiteStats::numberingroup( strtolower( $name ) ),
-                       $raw,
-                       $parser->getFunctionLang()
-               );
+               return self::formatRaw( SiteStats::numberingroup( strtolower( $name ) ), $raw );
        }
 
        /**
        }
 
        /**
@@ -745,7 +727,7 @@ class CoreParserFunctions {
 
                $title = Title::makeTitleSafe( NS_CATEGORY, $name );
                if ( !$title ) { # invalid title
 
                $title = Title::makeTitleSafe( NS_CATEGORY, $name );
                if ( !$title ) { # invalid title
-                       return self::formatRaw( 0, $raw, $parser->getFunctionLang() );
+                       return self::formatRaw( 0, $raw );
                }
                $wgContLang->findVariantLink( $name, $title, true );
 
                }
                $wgContLang->findVariantLink( $name, $title, true );
 
@@ -771,7 +753,7 @@ class CoreParserFunctions {
                }
 
                $count = $cache[$name][$type];
                }
 
                $count = $cache[$name][$type];
-               return self::formatRaw( $count, $raw, $parser->getFunctionLang() );
+               return self::formatRaw( $count, $raw );
        }
 
        /**
        }
 
        /**
@@ -787,7 +769,7 @@ class CoreParserFunctions {
                $title = Title::newFromText( $page );
 
                if ( !is_object( $title ) ) {
                $title = Title::newFromText( $page );
 
                if ( !is_object( $title ) ) {
-                       return self::formatRaw( 0, $raw, $parser->getFunctionLang() );
+                       return self::formatRaw( 0, $raw );
                }
 
                // fetch revision from cache/database and return the value
                }
 
                // fetch revision from cache/database and return the value
@@ -797,7 +779,7 @@ class CoreParserFunctions {
                        // We've had bugs where rev_len was not being recorded for empty pages, see T135414
                        $length = 0;
                }
                        // We've had bugs where rev_len was not being recorded for empty pages, see T135414
                        $length = 0;
                }
-               return self::formatRaw( $length, $raw, $parser->getFunctionLang() );
+               return self::formatRaw( $length, $raw );
        }
 
        /**
        }
 
        /**