From: Yuri Astrakhan Date: Sat, 16 Nov 2013 19:55:08 +0000 (-0500) Subject: Logic optimization for wfExpandUrl() X-Git-Tag: 1.31.0-rc.0~18090^2 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=5aa7c747ad043437888771b302b293ebfe35aee0;p=lhc%2Fweb%2Fwiklou.git Logic optimization for wfExpandUrl() removed redundant checks of the same variable, making the code slightly more efficient Change-Id: Ice4d3c45e80ca1214e2c36444baf0ce87b15a59b --- 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 );