From 20d5ffce4527428e256a43e8a4343e3415fcf5f4 Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Tue, 10 Jan 2006 22:13:18 +0000 Subject: [PATCH] fixed redirect-to-image bug --- includes/Wiki.php | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/includes/Wiki.php b/includes/Wiki.php index 8d62167e37..459af436ac 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -1,13 +1,23 @@ param[strtolower( $key )] = $value; } - + + /** + * Retrieves parameters + */ function getVal( $key, $default = "" ) { $key = strtolower( $key ); if( isset( $this->params[$key] ) ) { @@ -16,7 +26,11 @@ class MediaWiki { return $default; } - function initializeArticle( &$title, $request, $action ) { + /** + * Creates the article to be known as $wgArticle + */ + function initializeArticle( &$title, &$request, $action ) { + // Fix Media namespace if( NS_MEDIA == $title->getNamespace() ) { $title = Title::makeTitle( NS_IMAGE, $title->getDBkey() ); } @@ -31,22 +45,31 @@ class MediaWiki { # Reload from the page pointed to later $article->mContentLoaded = false; $ns = $rTitle->getNamespace(); + $wasRedirected = true; } } // Categories and images are handled by a different class if( $ns == NS_IMAGE ) { + $b4 = $title->getPrefixedText(); unset($article); require_once( 'includes/ImagePage.php' ); - return new ImagePage( $title ); + $article = new ImagePage( $title ); + if( isset( $wasRedirected ) ) { + $article->mTitle = $rTitle; + $article->mRedirectedFrom = $b4; + } } elseif( $ns == NS_CATEGORY ) { unset($article); require_once( 'includes/CategoryPage.php' ); - return new CategoryPage( $title ); + $article = new CategoryPage( $title ); } return $article; } + /** + * Performs any of a wide range of passed actions + */ function performAction( $action, &$output, &$article, &$title, &$user, &$request ) { switch( $action ) { case 'view': -- 2.20.1