From 2dd7e59f1749b0caea9ddbdbc6877862f2f04e3c Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Tue, 15 Apr 2008 17:32:23 +0000 Subject: [PATCH] (bug 13752) Section redirects now works again --- RELEASE-NOTES | 2 +- includes/Article.php | 16 ++++++++++++---- includes/Wiki.php | 3 +-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 8e91c1eebc..1fbc6c4be9 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -183,7 +183,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 13736) Don't show MediaWiki:Anontalkpagetext on non-existant IP addresses * (bug 13728) Don't trim initial whitespace during section edits * (bug 13727) Don't delete log entries from recentchanges on page deletion - +* (bug 13752) Section redirects now works again === API changes in 1.13 === diff --git a/includes/Article.php b/includes/Article.php index 3d444c2810..02c3cd610f 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -71,7 +71,7 @@ class Article { return $this->mRedirectTarget; # Query the redirect table - $dbr = wfGetDb(DB_SLAVE); + $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select('redirect', array('rd_namespace', 'rd_title'), array('rd_from' => $this->getID()), @@ -95,7 +95,7 @@ class Article { $retval = Title::newFromRedirect($this->getContent()); if(!$retval) return null; - $dbw = wfGetDb(DB_MASTER); + $dbw = wfGetDB(DB_MASTER); $dbw->insert('redirect', array( 'rd_from' => $this->getID(), 'rd_namespace' => $retval->getNamespace(), @@ -105,10 +105,18 @@ class Article { } /** + * Get the Title object this page redirects to + * + * @param bool $getFragment should the fragment be set on the title * @return mixed false, Title of in-wiki target, or string with URL */ - function followRedirect() { - $rt = $this->getRedirectTarget(); + function followRedirect( $getFragment = false ) { + if( $getFragment ) + // We'll need to use the content of this page, as Article::getRedirectTarget() + // now loads the data from redirect table, wich doesn't store the fragment + $rt = Title::newFromRedirect( $this->getContent() ); + else + $rt = $this->getRedirectTarget(); # process if title object is valid and not special:userlogout if( $rt ) { diff --git a/includes/Wiki.php b/includes/Wiki.php index 5559f0a922..49aaec9637 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -270,7 +270,6 @@ class MediaWiki { * * @param Title $title * @param Request $request - * @param string $action * @return mixed an Article, or a string to redirect to another URL */ function initializeArticle( &$title, $request ) { @@ -289,7 +288,7 @@ class MediaWiki { // Follow redirects only for... redirects if( $article->mIsRedirect ) { - $target = $article->followRedirect(); + $target = $article->followRedirect( true /* getFragment */ ); if( is_string( $target ) ) { if( !$this->getVal( 'DisableHardRedirects' ) ) { // we'll need to redirect -- 2.20.1