From 90763fe60db81ab295477afd0a0b87c14e3c3501 Mon Sep 17 00:00:00 2001 From: Steve Sanbeg Date: Tue, 1 May 2007 17:26:57 +0000 Subject: [PATCH] fix bug 9670: follow redirects in section edit links --- RELEASE-NOTES | 2 +- includes/EditPage.php | 2 +- includes/Parser.php | 15 +++++++++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 0eacfd1347..b3a0d183a4 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 diff --git a/includes/EditPage.php b/includes/EditPage.php index bec6e30081..4e6c3e8bb3 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -1497,7 +1497,7 @@ END $wgOut->setArticleRelated( false ); $wgOut->addWikiText( wfMsg( 'nosuchsectiontext', $this->section ) ); - $wgOut->returnToMain( false ); + $wgOut->returnToMain( false, $this->mTitle->getPrefixedUrl() ); } /** diff --git a/includes/Parser.php b/includes/Parser.php index 9bfe3ddc95..9004aea238 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -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; -- 2.20.1