From a344ffed30c664e6a98c5d37615cf9fd3d1d2b4b Mon Sep 17 00:00:00 2001 From: Platonides Date: Sun, 15 May 2011 12:34:00 +0000 Subject: [PATCH] Perform an early exit --- includes/Linker.php | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/includes/Linker.php b/includes/Linker.php index 3eaede6315..e4b9991074 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -760,34 +760,33 @@ class Linker { */ public static function makeBrokenImageLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '', $time = false ) { global $wgEnableUploads, $wgUploadMissingFileUrl; - if ( $title instanceof Title ) { - wfProfileIn( __METHOD__ ); - $currentExists = $time ? ( wfFindFile( $title ) != false ) : false; - - list( $inside, $trail ) = self::splitTrail( $trail ); - if ( $text == '' ) - $text = htmlspecialchars( $title->getPrefixedText() ); - - if ( ( $wgUploadMissingFileUrl || $wgEnableUploads ) && !$currentExists ) { - $redir = RepoGroup::singleton()->getLocalRepo()->checkRedirect( $title ); + if ( ! $title instanceof Title ) { + return "{$prefix}{$text}{$trail}"; + } + wfProfileIn( __METHOD__ ); + $currentExists = $time ? ( wfFindFile( $title ) != false ) : false; - if ( $redir ) { - wfProfileOut( __METHOD__ ); - return self::linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail; - } + list( $inside, $trail ) = self::splitTrail( $trail ); + if ( $text == '' ) + $text = htmlspecialchars( $title->getPrefixedText() ); - $href = self::getUploadUrl( $title, $query ); + if ( ( $wgUploadMissingFileUrl || $wgEnableUploads ) && !$currentExists ) { + $redir = RepoGroup::singleton()->getLocalRepo()->checkRedirect( $title ); - wfProfileOut( __METHOD__ ); - return '' . - "$prefix$text$inside$trail"; - } else { + if ( $redir ) { wfProfileOut( __METHOD__ ); return self::linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail; } + + $href = self::getUploadUrl( $title, $query ); + + wfProfileOut( __METHOD__ ); + return '' . + "$prefix$text$inside$trail"; } else { - return "{$prefix}{$text}{$trail}"; + wfProfileOut( __METHOD__ ); + return self::linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail; } } -- 2.20.1