Remove usage of deprecated makeKnownLinkObj().
authorPlatonides <platonides@users.mediawiki.org>
Sat, 4 Sep 2010 22:25:59 +0000 (22:25 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Sat, 4 Sep 2010 22:25:59 +0000 (22:25 +0000)
Added a parserTest for each call of the old makeKnownLinkObj (and checked that they pass now with linkKnown).

includes/Linker.php
maintenance/parserTests.inc
maintenance/parserTests.txt

index e1ebbbe..5e3d48b 100644 (file)
@@ -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 '<a href="' . htmlspecialchars( $href ) . '" class="new" title="' .
                                                                htmlspecialchars( $title->getPrefixedText(), ENT_QUOTES ) . '">' .
                                                                htmlspecialchars( $prefix . $text . $inside, ENT_NOQUOTES ) . '</a>' . $trail;
                        } else {
                                wfProfileOut( __METHOD__ );
-                               return $this->makeKnownLinkObj( $title, $text, $query, $trail, $prefix );
+                               return $this->linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail;
                        }
                } else {
                        return "<!-- ERROR -->{$prefix}{$text}{$trail}";
index b30d3c2..b15af35 100644 (file)
@@ -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',
index 6524c61..43ac4bf 100644 (file)
@@ -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
+<p><a href="/wiki/File:Barfoo.jpg" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
+</p>
+!! end
+
+!! test
+Missing image with uploads disabled
+!! options
+wgEnableUploads=0
+!! input
+[[Image:Foobaz.jpg]]
+!! result
+<p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
+</p>
+!! end
+
 
 ###
 ### Subpages