Re-do several things of r96798 in preparation of re-doing the rest (there's a bug...
authorRobin Pepermans <robin@users.mediawiki.org>
Tue, 20 Sep 2011 15:55:08 +0000 (15:55 +0000)
committerRobin Pepermans <robin@users.mediawiki.org>
Tue, 20 Sep 2011 15:55:08 +0000 (15:55 +0000)
* Do additional validation and is_array() check in LanguageConverter
* Make redirects be in content language again (remove from Title->getPageLanguage())
* Pass title object from ParserCache to ParserOptions->optionsHash

includes/Article.php
includes/Title.php
includes/parser/ParserOptions.php
languages/LanguageConverter.php

index 3dcef85..a91ad26 100644 (file)
@@ -1050,13 +1050,14 @@ class Article extends Page {
         * @return string containing HMTL with redirect link
         */
        public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
-               global $wgOut, $wgLang, $wgStylePath;
+               global $wgOut, $wgStylePath;
 
                if ( !is_array( $target ) ) {
                        $target = array( $target );
                }
 
-               $imageDir = $wgLang->getDir();
+               $lang = $this->getTitle()->getPageLanguage();
+               $imageDir = $lang->getDir();
 
                if ( $appendSubtitle ) {
                        $wgOut->appendSubtitle( wfMsgHtml( 'redirectpagesub' ) );
@@ -1072,7 +1073,7 @@ class Article extends Page {
                }
 
                $nextRedirect = $wgStylePath . '/common/images/nextredirect' . $imageDir . '.png';
-               $alt = $wgLang->isRTL() ? '←' : '→';
+               $alt = $lang->isRTL() ? '←' : '→';
                // Automatically append redirect=no to each link, since most of them are redirect pages themselves.
                foreach ( $target as $rt ) {
                        $link .= Html::element( 'img', array( 'src' => $nextRedirect, 'alt' => $alt ) );
index 14ac5ba..dedb7ac 100644 (file)
@@ -4376,9 +4376,6 @@ class Title {
                if ( $this->getNamespace() == NS_SPECIAL ) {
                        // special pages are in the user language
                        return $wgLang;
-               } elseif ( $this->isRedirect() ) {
-                       // the arrow on a redirect page is aligned according to the user language
-                       return $wgLang;
                } elseif ( $this->isCssOrJsPage() ) {
                        // css/js should always be LTR and is, in fact, English
                        return wfGetLangObj( 'en' );
index 2ecfce4..c545747 100644 (file)
@@ -274,9 +274,11 @@ class ParserOptions {
         * settings.
         *
         * @since 1.17
+        * @param $forOptions Array
+        * @param $title Title: will be used to get the page content language
         * @return \string Page rendering hash
         */
-       public function optionsHash( $forOptions ) {
+       public function optionsHash( $forOptions, $title = null ) {
                global $wgContLang, $wgRenderHashAppend;
 
                $confstr = '';
index ba89be7..7d399e3 100644 (file)
@@ -158,7 +158,7 @@ class LanguageConverter {
                // not memoized (i.e. there return value is not cached) since
                // new information might appear during processing after this
                // is first called.
-               if ( $req ) {
+               if ( $this->validateVariant( $req ) ) {
                        return $req;
                }
                return $this->mMainLanguageCode;
@@ -1369,14 +1369,16 @@ class ConverterRule {
                                   // then we check its fallback variants.
                                $variantFallbacks =
                                        $this->mConverter->getVariantFallbacks( $variant );
-                               foreach ( $variantFallbacks as $variantFallback ) {
-                                       // if current variant's fallback exist in flags
-                                       if ( isset( $this->mVariantFlags[$variantFallback] ) ) {
-                                               // then convert <text to convert> to fallback language
-                                               $this->mRules =
-                                                       $this->mConverter->autoConvert( $this->mRules,
-                                                                                                                       $variantFallback );
-                                               break;
+                               if( is_array( $variantFallbacks ) ) {
+                                       foreach ( $variantFallbacks as $variantFallback ) {
+                                               // if current variant's fallback exist in flags
+                                               if ( isset( $this->mVariantFlags[$variantFallback] ) ) {
+                                                       // then convert <text to convert> to fallback language
+                                                       $this->mRules =
+                                                               $this->mConverter->autoConvert( $this->mRules,
+                                                                                                                               $variantFallback );
+                                                       break;
+                                               }
                                        }
                                }
                        }