From 8f3a851aa284cc531fd3f126380603d1689271f7 Mon Sep 17 00:00:00 2001 From: Platonides Date: Sat, 4 Sep 2010 22:25:59 +0000 Subject: [PATCH] Remove usage of deprecated makeKnownLinkObj(). Added a parserTest for each call of the old makeKnownLinkObj (and checked that they pass now with linkKnown). --- includes/Linker.php | 16 ++++++++-------- maintenance/parserTests.inc | 2 +- maintenance/parserTests.txt | 26 ++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/includes/Linker.php b/includes/Linker.php index e1ebbbe58b..5e3d48b77a 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -687,28 +687,28 @@ class Linker { if ( $title instanceof Title ) { wfProfileIn( __METHOD__ ); $currentExists = $time ? ( wfFindFile( $title ) != false ) : false; - if ( ( $wgUploadMissingFileUrl || $wgEnableUploads ) && !$currentExists ) { - if ( $text == '' ) - $text = htmlspecialchars( $title->getPrefixedText() ); + list( $inside, $trail ) = self::splitTrail( $trail ); + if ( $text == '' ) + $text = htmlspecialchars( $title->getPrefixedText() ); + + if ( ( $wgUploadMissingFileUrl || $wgEnableUploads ) && !$currentExists ) { $redir = RepoGroup::singleton()->getLocalRepo()->checkRedirect( $title ); + if ( $redir ) { wfProfileOut( __METHOD__ ); - return $this->makeKnownLinkObj( $title, $text, $query, $trail, $prefix ); + return $this->linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail; } $href = $this->getUploadUrl( $title, $query ); - - list( $inside, $trail ) = self::splitTrail( $trail ); - wfProfileOut( __METHOD__ ); return '' . htmlspecialchars( $prefix . $text . $inside, ENT_NOQUOTES ) . '' . $trail; } else { wfProfileOut( __METHOD__ ); - return $this->makeKnownLinkObj( $title, $text, $query, $trail, $prefix ); + return $this->linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail; } } else { return "{$prefix}{$text}{$trail}"; diff --git a/maintenance/parserTests.inc b/maintenance/parserTests.inc index b30d3c264c..b15af35a56 100644 --- a/maintenance/parserTests.inc +++ b/maintenance/parserTests.inc @@ -545,7 +545,7 @@ class ParserTest { 'hashLevels' => 2, 'transformVia404' => false, ), - 'wgEnableUploads' => true, + 'wgEnableUploads' => self::getOptionValue( 'wgEnableUploads', $opts, true ), 'wgStyleSheetPath' => '/skins', 'wgSitename' => 'MediaWiki', 'wgServerName' => 'Britney-Spears', diff --git a/maintenance/parserTests.txt b/maintenance/parserTests.txt index 6524c6157e..43ac4bfc8d 100644 --- a/maintenance/parserTests.txt +++ b/maintenance/parserTests.txt @@ -3568,6 +3568,32 @@ Bug 3090: External links other than http: in image captions !! end +!! article +File:Barfoo.jpg +!! text +#REDIRECT [[File:Barfoo.jpg]] +!! endarticle + +!! test +Redirected image +!! input +[[Image:Barfoo.jpg]] +!! result +

File:Barfoo.jpg +

+!! end + +!! test +Missing image with uploads disabled +!! options +wgEnableUploads=0 +!! input +[[Image:Foobaz.jpg]] +!! result +

File:Foobaz.jpg +

+!! end + ### ### Subpages -- 2.20.1