(bug 13943) Fix image redirect behaviour on image pages:

* Confused redirect source with target
* Don't check for article existence if the target is a foreign image page
This commit is contained in:
Bryan Tong Minh 2008-05-10 11:12:53 +00:00
parent dbbdc5dab2
commit ddf879fccf
3 changed files with 15 additions and 3 deletions

View file

@ -268,6 +268,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
* (bug 12644) Template list on edit page now sorted on preview
* (bug 14058) Support pipe trick for namespaces and interwikis with "-"
* Message name filter on Special:Allmessages now case-insensitive
* (bug 13943) Fix image redirect behaviour on image pages
=== API changes in 1.13 ===

View file

@ -111,14 +111,18 @@ class ImagePage extends Article {
// Foreign image page
$from = $this->img->getRedirected();
return $this->mRedirectTarget = Title::makeTitle( NS_IMAGE, $from );
$to = $this->img->getName();
if ($from == $to) return null;
return $this->mRedirectTarget = Title::makeTitle( NS_IMAGE, $to );
}
public function followRedirect() {
if ( $this->img->isLocal() )
return parent::followRedirect();
$from = $this->img->getRedirected();
return Title::makeTitle( NS_IMAGE, $from );
$to = $this->img->getName();
if ($from == $to) return false;
return Title::makeTitle( NS_IMAGE, $to );
}
public function isRedirect( $text = false ) {
if ( $this->img->isLocal() )
@ -126,6 +130,10 @@ class ImagePage extends Article {
return (bool)$this->img->getRedirected();
}
public function isLocal() {
return $this->img->isLocal();
}
/**
* Create the TOC

View file

@ -297,11 +297,14 @@ class MediaWiki {
return $target;
}
}
if( is_object( $target ) ) {
// Rewrite environment to redirected article
$rarticle = self::articleFromTitle( $target );
$rarticle->loadPageData( $rarticle->pageDataFromTitle( $dbr, $target ) );
if ( $rarticle->getTitle()->exists() ) {
if ( $rarticle->getTitle()->exists() ||
( $title->getNamespace() == NS_IMAGE &&
!$article->isLocal() ) ) {
$rarticle->setRedirectedFrom( $title );
$article = $rarticle;
$title = $target;