jenkins-bot has submitted this change and it was merged.

Change subject: Logic optimization for wfExpandUrl()
......................................................................


Logic optimization for wfExpandUrl()

removed redundant checks of the same variable, making the code
slightly more efficient

Change-Id: Ice4d3c45e80ca1214e2c36444baf0ce87b15a59b
---
M includes/GlobalFunctions.php
1 file changed, 8 insertions(+), 7 deletions(-)

Approvals:
  Brian Wolff: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php
index 1eb5c3e..688300a 100644
--- a/includes/GlobalFunctions.php
+++ b/includes/GlobalFunctions.php
@@ -496,17 +496,18 @@
  */
 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 );

-- 
To view, visit https://gerrit.wikimedia.org/r/92041
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ice4d3c45e80ca1214e2c36444baf0ce87b15a59b
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Yurik <yu...@wikimedia.org>
Gerrit-Reviewer: Brian Wolff <bawolff...@gmail.com>
Gerrit-Reviewer: Ori.livneh <o...@wikimedia.org>
Gerrit-Reviewer: Parent5446 <tylerro...@gmail.com>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to