fix bug 9670: follow redirects in section edit links
authorSteve Sanbeg <sanbeg@users.mediawiki.org>
Tue, 1 May 2007 17:26:57 +0000 (17:26 +0000)
committerSteve Sanbeg <sanbeg@users.mediawiki.org>
Tue, 1 May 2007 17:26:57 +0000 (17:26 +0000)
RELEASE-NOTES
includes/EditPage.php
includes/Parser.php

index 0eacfd1..b3a0d18 100644 (file)
@@ -373,7 +373,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 7629) Fix $wgBrowserBlackList to avoid false positive on MSIE
   when certain plugins are present which alter the user agent
 * (bug 9712) Use Arabic comma in date/time formats for Arabic and Farsi
-
+* (bug 9670) Follow redirects when render edit section links to transcluded templates.
 == Maintenance ==
 
 * New script maintenance/language/checkExtensioni18n.php used to check i18n
index bec6e30..4e6c3e8 100644 (file)
@@ -1497,7 +1497,7 @@ END
                $wgOut->setArticleRelated( false );
 
                $wgOut->addWikiText( wfMsg( 'nosuchsectiontext', $this->section ) );
-               $wgOut->returnToMain( false );
+               $wgOut->returnToMain( false, $this->mTitle->getPrefixedUrl() );
        }
 
        /**
index 9bfe3dd..9004aea 100644 (file)
@@ -3212,14 +3212,25 @@ class Parser
                                # replace ==section headers==
                                # XXX this needs to go away once we have a better parser.
                                if ( !$this->ot['wiki'] && !$this->ot['pre'] && $replaceHeadings ) {
-                                       if( !is_null( $title ) )
-                                               $encodedname = base64_encode($title->getPrefixedDBkey());
+                                      if( !is_null( $title ) ) {
+                                   
+                                               #Follow redirects
+                                               $redirect = new Article($title);
+                                               $redirect = $redirect->followRedirect();
+                                               if( ! ($redirect instanceof Title))
+                                                       $redirect = $title;
+                                        
+
+                                               $encodedname = base64_encode($redirect->getPrefixedDBkey());
+                                       }
+                                 
                                        else
                                                $encodedname = base64_encode("");
                                        $m = preg_split('/(^={1,6}.*?={1,6}\s*?$)/m', $text, -1,
                                                PREG_SPLIT_DELIM_CAPTURE);
                                        $text = '';
                                        $nsec = $headingOffset;
+
                                        for( $i = 0; $i < count($m); $i += 2 ) {
                                                $text .= $m[$i];
                                                if (!isset($m[$i + 1]) || $m[$i + 1] == "") continue;