Followup r105812:
authorDaniel Friesen <dantman@users.mediawiki.org>
Mon, 12 Dec 2011 20:09:06 +0000 (20:09 +0000)
committerDaniel Friesen <dantman@users.mediawiki.org>
Mon, 12 Dec 2011 20:09:06 +0000 (20:09 +0000)
- Fix case of the wfBCP47 call
- Don't call wfBCP47 for every time getHtmlCode is called
- Add @since

languages/Language.php

index a712246..fe4f8a4 100644 (file)
@@ -61,6 +61,7 @@ class Language {
 
        var $mVariants, $mCode, $mLoaded = false;
        var $mMagicExtensions = array(), $mMagicHookDone = false;
+       private $mHtmlCode = null;
 
        var $mNamespaceIds, $namespaceNames, $namespaceAliases;
        var $dateFormatStrings = array();
@@ -3467,9 +3468,13 @@ class Language {
        /**
         * Get the code in Bcp47 format which we can use
         * inside of html lang="" tags.
+        * @since 1.19
         */
        function getHtmlCode() {
-               return wfBcp47( $this->getCode() );
+               if ( is_null( $this->mHtmlCode ) ) {
+                       $this->mHtmlCode = wfBCP47( $this->getCode() );
+               }
+               return $this->mHtmlCode;
        }
 
        /**
@@ -3477,6 +3482,8 @@ class Language {
         */
        function setCode( $code ) {
                $this->mCode = $code;
+               // Ensure we don't leave an incorrect html code lying around
+               unset( $this->mHtmlCode );
        }
 
        /**