From 5aa7c747ad043437888771b302b293ebfe35aee0 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Sat, 16 Nov 2013 14:55:08 -0500 Subject: [PATCH] Logic optimization for wfExpandUrl() removed redundant checks of the same variable, making the code slightly more efficient Change-Id: Ice4d3c45e80ca1214e2c36444baf0ce87b15a59b --- includes/GlobalFunctions.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 1eb5c3e62a..688300aaee 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -496,17 +496,18 @@ function wfAppendQuery( $url, $query ) { */ function wfExpandUrl( $url, $defaultProto = PROTO_CURRENT ) { global $wgServer, $wgCanonicalServer, $wgInternalServer, $wgRequest; - $serverUrl = $wgServer; if ( $defaultProto === PROTO_CANONICAL ) { $serverUrl = $wgCanonicalServer; - } - // Make $wgInternalServer fall back to $wgServer if not set - if ( $defaultProto === PROTO_INTERNAL && $wgInternalServer !== false ) { + } elseif ( $defaultProto === PROTO_INTERNAL && $wgInternalServer !== false ) { + // Make $wgInternalServer fall back to $wgServer if not set $serverUrl = $wgInternalServer; + } else { + $serverUrl = $wgServer; + if ( $defaultProto === PROTO_CURRENT ) { + $defaultProto = $wgRequest->getProtocol() . '://'; + } } - if ( $defaultProto === PROTO_CURRENT ) { - $defaultProto = $wgRequest->getProtocol() . '://'; - } + // Analyze $serverUrl to obtain its protocol $bits = wfParseUrl( $serverUrl ); -- 2.20.1