From 6bac96af7e16282ccf6b2ce29212c0d10181231b Mon Sep 17 00:00:00 2001 From: Ryan Schmidt Date: Tue, 22 Feb 2011 16:39:17 +0000 Subject: [PATCH] * random redirect-related fixes: ** automatically add redirect=no to all links on the redirect page in Article::viewRedirect. ** properly check if redirects are enabled if $wgMaxRedirects < 1 (moved check from Title::newFromRedirectArray to Title::newFromRedirectInternal). --- includes/Article.php | 5 ++--- includes/Title.php | 9 +++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 6504d3af49..1d8f68bd2c 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1564,13 +1564,12 @@ class Article { $nextRedirect = $wgStylePath . '/common/images/nextredirect' . $imageDir . '.png'; $alt = $wgContLang->isRTL() ? '←' : '→'; // Automatically append redirect=no to each link, since most of them are redirect pages themselves. - // FIXME: where this happens? foreach ( $target as $rt ) { $link .= Html::element( 'img', array( 'src' => $nextRedirect, 'alt' => $alt ) ); if ( $forceKnown ) { - $link .= $sk->linkKnown( $rt, htmlspecialchars( $rt->getFullText() ) ); + $link .= $sk->linkKnown( $rt, htmlspecialchars( $rt->getFullText(), array(), array( 'redirect' => 'no' ) ) ); } else { - $link .= $sk->link( $rt, htmlspecialchars( $rt->getFullText() ) ); + $link .= $sk->link( $rt, htmlspecialchars( $rt->getFullText() ), array(), array( 'redirect' => 'no' ) ); } } diff --git a/includes/Title.php b/includes/Title.php index e2e8dee67b..409467bbdf 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -359,10 +359,6 @@ class Title { */ public static function newFromRedirectArray( $text ) { global $wgMaxRedirects; - // are redirects disabled? - if ( $wgMaxRedirects < 1 ) { - return null; - } $title = self::newFromRedirectInternal( $text ); if ( is_null( $title ) ) { return null; @@ -397,6 +393,11 @@ class Title { * @return Title */ protected static function newFromRedirectInternal( $text ) { + global $wgMaxRedirects; + if ( $wgMaxRedirects < 1 ) { + //redirects are disabled, so quit early + return null; + } $redir = MagicWord::get( 'redirect' ); $text = trim( $text ); if ( $redir->matchStartAndRemove( $text ) ) { -- 2.20.1