Merge "benchmarker: Implement setupEach for per-iteration setup"
[lhc/web/wiklou.git] / languages / Language.php
index 7f04a68..eab09a1 100644 (file)
@@ -244,6 +244,24 @@ class Language {
                throw new MWException( "Invalid fallback sequence for language '$code'" );
        }
 
+       /**
+        * Intended for tests that may change configuration in a way that invalidates caches.
+        *
+        * @since 1.32
+        */
+       public static function clearCaches() {
+               if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
+                       throw new MWException( __METHOD__ . ' must not be used outside tests' );
+               }
+               self::$dataCache = null;
+               // Reinitialize $dataCache, since it's expected to always be available
+               self::getLocalisationCache();
+               self::$mLangObjCache = [];
+               self::$fallbackLanguageCache = [];
+               self::$grammarTransformations = null;
+               self::$languageNameCache = null;
+       }
+
        /**
         * Checks whether any localisation is available for that language tag
         * in MediaWiki (MessagesXx.php exists).
@@ -532,7 +550,7 @@ class Language {
         * Get a namespace value by key
         *
         * <code>
-        * $mw_ns = $wgContLang->getNsText( NS_MEDIAWIKI );
+        * $mw_ns = $lang->getNsText( NS_MEDIAWIKI );
         * echo $mw_ns; // prints 'MediaWiki'
         * </code>
         *
@@ -550,7 +568,7 @@ class Language {
         * producing output.
         *
         * <code>
-        * $mw_ns = $wgContLang->getFormattedNsText( NS_MEDIAWIKI_TALK );
+        * $mw_ns = $lang->getFormattedNsText( NS_MEDIAWIKI_TALK );
         * echo $mw_ns; // prints 'MediaWiki talk'
         * </code>
         *
@@ -2996,7 +3014,7 @@ class Language {
         *
         * @return string
         */
-       function normalize( $s ) {
+       public function normalize( $s ) {
                global $wgAllUnicodeFixes;
                $s = UtfNormal\Validator::cleanUp( $s );
                if ( $wgAllUnicodeFixes ) {