* random redirect-related fixes:
authorRyan Schmidt <skizzerz@users.mediawiki.org>
Tue, 22 Feb 2011 16:39:17 +0000 (16:39 +0000)
committerRyan Schmidt <skizzerz@users.mediawiki.org>
Tue, 22 Feb 2011 16:39:17 +0000 (16:39 +0000)
** 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
includes/Title.php

index 6504d3a..1d8f68b 100644 (file)
@@ -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' ) );
                        }
                }
 
index e2e8dee..409467b 100644 (file)
@@ -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 ) ) {