*Re-implement r40723 in Article::view()
[lhc/web/wiklou.git] / languages / Language.php
index 5138261..364231a 100644 (file)
@@ -39,7 +39,7 @@ class FakeConverter {
        function parserConvert($t, $p) {return $t;}
        function getVariants() { return array( $this->mLang->getCode() ); }
        function getPreferredVariant() {return $this->mLang->getCode(); }
-       function findVariantLink(&$l, &$n) {}
+       function findVariantLink(&$l, &$n, $forTemplate = false) {}
        function getExtraHashOptions() {return '';}
        function getParsedTitle() {return '';}
        function markNoConversion($text, $noParse=false) {return $text;}
@@ -176,6 +176,15 @@ class Language {
                }
        }
 
+       /**
+        * Reduce memory usage
+        */
+       function __destruct() {
+               foreach ( $this as $name => $value ) {
+                       unset( $this->$name );
+               }
+       }
+
        /**
         * Hook which will be called if this is the content language.
         * Descendants can use this to register hook functions or modify globals
@@ -1689,7 +1698,9 @@ class Language {
                        } else {
                                # Fall back to English if local list is incomplete
                                $magicWords =& Language::getMagicWords();
-                               if ( !isset($magicWords[$mw->mId]) ) { throw new MWException("Magic word not found" ); }
+                               if ( !isset($magicWords[$mw->mId]) ) {
+                                       throw new MWException("Magic word '{$mw->mId}' not found" ); 
+                               }
                                $rawEntry = $magicWords[$mw->mId];
                        }
                }
@@ -1813,7 +1824,7 @@ class Language {
          * LanguageIs.php for the , => . and . => , implementation.
          *
          * @todo check if it's viable to use localeconv() for the decimal
-         *       seperator thing.
+         *       separator thing.
          * @param $number Mixed: the string to be formatted, should be an integer
          *        or a floating point number.
          * @param $nocommafy Bool: set to true for special numbers like dates
@@ -1970,7 +1981,7 @@ class Language {
                if ( !count($forms) ) { return ''; }
                $forms = $this->preConvertPlural( $forms, 2 );
 
-               return ( abs($count) == 1 ) ? $forms[0] : $forms[1];
+               return ( $count == 1 ) ? $forms[0] : $forms[1];
        }
 
        /**
@@ -2096,8 +2107,8 @@ class Language {
         * @param $nt Mixed: the title object of the link
         * @return null the input parameters may be modified upon return
         */
-       function findVariantLink( &$link, &$nt ) {
-               $this->mConverter->findVariantLink($link, $nt);
+       function findVariantLink( &$link, &$nt, $forTemplate = false ) {
+               $this->mConverter->findVariantLink($link, $nt, $forTemplate );
        }
 
        /**