From 3fc94ebd11723676739de45c620a55bbea56dce7 Mon Sep 17 00:00:00 2001 From: Robin Pepermans Date: Tue, 20 Sep 2011 15:55:08 +0000 Subject: [PATCH] Re-do several things of r96798 in preparation of re-doing the rest (there's a bug somewhere that needs fixing). * 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 | 7 ++++--- includes/Title.php | 3 --- includes/parser/ParserOptions.php | 4 +++- languages/LanguageConverter.php | 20 +++++++++++--------- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 3dcef85a52..a91ad2642e 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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 ) ); diff --git a/includes/Title.php b/includes/Title.php index 14ac5ba02e..dedb7ac024 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -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' ); diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php index 2ecfce4bcc..c545747d4e 100644 --- a/includes/parser/ParserOptions.php +++ b/includes/parser/ParserOptions.php @@ -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 = ''; diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index ba89be741b..7d399e3c41 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -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 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 to fallback language + $this->mRules = + $this->mConverter->autoConvert( $this->mRules, + $variantFallback ); + break; + } } } } -- 2.20.1