Merge "Simplify ternary construction"
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index 1eb5c3e..819b076 100644 (file)
@@ -496,16 +496,16 @@ 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;
-       }
-       if ( $defaultProto === PROTO_CURRENT ) {
-               $defaultProto = $wgRequest->getProtocol() . '://';
+       } else {
+               $serverUrl = $wgServer;
+               if ( $defaultProto === PROTO_CURRENT ) {
+                       $defaultProto = $wgRequest->getProtocol() . '://';
+               }
        }
 
        // Analyze $serverUrl to obtain its protocol
@@ -965,8 +965,8 @@ function wfIsDebugRawPage() {
                || (
                        isset( $_SERVER['SCRIPT_NAME'] )
                        && substr( $_SERVER['SCRIPT_NAME'], -8 ) == 'load.php'
-               ) )
-       {
+               )
+       {
                $cache = true;
        } else {
                $cache = false;
@@ -1463,9 +1463,9 @@ function wfMsgForContent( $key ) {
        $args = func_get_args();
        array_shift( $args );
        $forcontent = true;
-       if ( is_array( $wgForceUIMsgAsContentMsg ) &&
-               in_array( $key, $wgForceUIMsgAsContentMsg ) )
-       {
+       if ( is_array( $wgForceUIMsgAsContentMsg )
+               && in_array( $key, $wgForceUIMsgAsContentMsg )
+       {
                $forcontent = false;
        }
        return wfMsgReal( $key, $args, true, $forcontent );
@@ -1486,9 +1486,9 @@ function wfMsgForContentNoTrans( $key ) {
        $args = func_get_args();
        array_shift( $args );
        $forcontent = true;
-       if ( is_array( $wgForceUIMsgAsContentMsg ) &&
-               in_array( $key, $wgForceUIMsgAsContentMsg ) )
-       {
+       if ( is_array( $wgForceUIMsgAsContentMsg )
+               && in_array( $key, $wgForceUIMsgAsContentMsg )
+       {
                $forcontent = false;
        }
        return wfMsgReal( $key, $args, true, $forcontent, false );
@@ -1993,11 +1993,11 @@ function wfClientAcceptsGzip( $force = false ) {
                        # @todo FIXME: We may want to blacklist some broken browsers
                        $m = array();
                        if ( preg_match(
-                               '/\bgzip(?:;(q)=([0-9]+(?:\.[0-9]+)))?\b/',
-                               $_SERVER['HTTP_ACCEPT_ENCODING'],
-                               $m )
-                       )
-                       {
+                                       '/\bgzip(?:;(q)=([0-9]+(?:\.[0-9]+)))?\b/',
+                                       $_SERVER['HTTP_ACCEPT_ENCODING'],
+                                       $m
+                               )
+                       {
                                if ( isset( $m[2] ) && ( $m[1] == 'q' ) && ( $m[2] == 0 ) ) {
                                        $result = false;
                                        return $result;
@@ -2770,11 +2770,11 @@ function wfShellExecDisabled() {
  * @param array $environ optional environment variables which should be
  *                 added to the executed command environment.
  * @param array $limits optional array with limits(filesize, memory, time, walltime)
- *                 this overwrites the global wgShellMax* limits.
+ *                 this overwrites the global wgMaxShell* limits.
  * @param array $options Array of options:
- *    - duplicateStderr: Set this to true to duplicate stderr to stdout, 
+ *    - duplicateStderr: Set this to true to duplicate stderr to stdout,
  *      including errors from limit.sh
- *      
+ *
  * @return string collected stdout as a string
  */
 function wfShellExec( $cmd, &$retval = null, $environ = array(),
@@ -2877,9 +2877,9 @@ function wfShellExec( $cmd, &$retval = null, $environ = array(),
        $logMsg = false;
 
        // According to the documentation, it is possible for stream_select()
-       // to fail due to EINTR. I haven't managed to induce this in testing 
-       // despite sending various signals. If it did happen, the error 
-       // message would take the form: 
+       // to fail due to EINTR. I haven't managed to induce this in testing
+       // despite sending various signals. If it did happen, the error
+       // message would take the form:
        //
        // stream_select(): unable to select [4]: Interrupted system call (max_fd=5)
        //
@@ -3513,7 +3513,6 @@ function wfResetSessionID() {
        wfRunHooks( 'ResetSessionID', array( $oldSessionId, $newSessionId ) );
 }
 
-
 /**
  * Initialise php session
  *
@@ -3809,7 +3808,7 @@ function wfGetNull() {
  * @param string|bool $cluster Cluster name accepted by LBFactory. Default: false.
  */
 function wfWaitForSlaves( $maxLag = false, $wiki = false, $cluster = false ) {
-       if( $cluster !== false ) {
+       if ( $cluster !== false ) {
                $lb = wfGetLBFactory()->getExternalLB( $cluster );
        } else {
                $lb = wfGetLB( $wiki );