r72398 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72397‎ | r72398 | r72399 >
Date:22:25, 4 September 2010
Author:platonides
Status:ok
Tags:
Comment:
Remove usage of deprecated makeKnownLinkObj().
Added a parserTest for each call of the old makeKnownLinkObj (and checked that they pass now with linkKnown).
Modified paths:
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/maintenance/parserTests.inc (modified) (history)
  • /trunk/phase3/maintenance/parserTests.txt (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/parserTests.inc
@@ -545,7 +545,7 @@
546546 'hashLevels' => 2,
547547 'transformVia404' => false,
548548 ),
549 - 'wgEnableUploads' => true,
 549+ 'wgEnableUploads' => self::getOptionValue( 'wgEnableUploads', $opts, true ),
550550 'wgStyleSheetPath' => '/skins',
551551 'wgSitename' => 'MediaWiki',
552552 'wgServerName' => 'Britney-Spears',
Index: trunk/phase3/maintenance/parserTests.txt
@@ -3568,7 +3568,33 @@
35693569
35703570 !! end
35713571
 3572+!! article
 3573+File:Barfoo.jpg
 3574+!! text
 3575+#REDIRECT [[File:Barfoo.jpg]]
 3576+!! endarticle
35723577
 3578+!! test
 3579+Redirected image
 3580+!! input
 3581+[[Image:Barfoo.jpg]]
 3582+!! result
 3583+<p><a href="https://www.mediawiki.org/wiki/File:Barfoo.jpg" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
 3584+</p>
 3585+!! end
 3586+
 3587+!! test
 3588+Missing image with uploads disabled
 3589+!! options
 3590+wgEnableUploads=0
 3591+!! input
 3592+[[Image:Foobaz.jpg]]
 3593+!! result
 3594+<p><a href="https://www.mediawiki.org/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
 3595+</p>
 3596+!! end
 3597+
 3598+
35733599 ###
35743600 ### Subpages
35753601 ###
Index: trunk/phase3/includes/Linker.php
@@ -687,28 +687,28 @@
688688 if ( $title instanceof Title ) {
689689 wfProfileIn( __METHOD__ );
690690 $currentExists = $time ? ( wfFindFile( $title ) != false ) : false;
 691+
 692+ list( $inside, $trail ) = self::splitTrail( $trail );
 693+ if ( $text == '' )
 694+ $text = htmlspecialchars( $title->getPrefixedText() );
 695+
691696 if ( ( $wgUploadMissingFileUrl || $wgEnableUploads ) && !$currentExists ) {
692 - if ( $text == '' )
693 - $text = htmlspecialchars( $title->getPrefixedText() );
 697+ $redir = RepoGroup::singleton()->getLocalRepo()->checkRedirect( $title );
694698
695 - $redir = RepoGroup::singleton()->getLocalRepo()->checkRedirect( $title );
696699 if ( $redir ) {
697700 wfProfileOut( __METHOD__ );
698 - return $this->makeKnownLinkObj( $title, $text, $query, $trail, $prefix );
 701+ return $this->linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail;
699702 }
700703
701704 $href = $this->getUploadUrl( $title, $query );
702705
703 -
704 - list( $inside, $trail ) = self::splitTrail( $trail );
705 -
706706 wfProfileOut( __METHOD__ );
707707 return '<a href="' . htmlspecialchars( $href ) . '" class="new" title="' .
708708 htmlspecialchars( $title->getPrefixedText(), ENT_QUOTES ) . '">' .
709709 htmlspecialchars( $prefix . $text . $inside, ENT_NOQUOTES ) . '</a>' . $trail;
710710 } else {
711711 wfProfileOut( __METHOD__ );
712 - return $this->makeKnownLinkObj( $title, $text, $query, $trail, $prefix );
 712+ return $this->linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail;
713713 }
714714 } else {
715715 return "<!-- ERROR -->{$prefix}{$text}{$trail}";

Status & tagging log