Merge "Remove useless PHP version comparison from wfDebugBacktrace()"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 29 Feb 2016 14:40:59 +0000 (14:40 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 29 Feb 2016 14:40:59 +0000 (14:40 +0000)
1  2 
includes/GlobalFunctions.php

@@@ -1557,7 -1557,7 +1557,7 @@@ function wfDebugBacktrace( $limit = 0 
                return [];
        }
  
-       if ( $limit && version_compare( PHP_VERSION, '5.4.0', '>=' ) ) {
+       if ( $limit ) {
                return array_slice( debug_backtrace( DEBUG_BACKTRACE_PROVIDE_OBJECT, $limit + 1 ), 1 );
        } else {
                return array_slice( debug_backtrace(), 1 );
@@@ -1949,9 -1949,9 +1949,9 @@@ function mimeTypeMatch( $type, $avail 
        if ( array_key_exists( $type, $avail ) ) {
                return $type;
        } else {
 -              $parts = explode( '/', $type );
 -              if ( array_key_exists( $parts[0] . '/*', $avail ) ) {
 -                      return $parts[0] . '/*';
 +              $mainType = explode( '/', $type )[0];
 +              if ( array_key_exists( "$mainType/*", $avail ) ) {
 +                      return "$mainType/*";
                } elseif ( array_key_exists( '*/*', $avail ) ) {
                        return '*/*';
                } else {
@@@ -1977,8 -1977,8 +1977,8 @@@ function wfNegotiateType( $cprefs, $spr
        $combine = [];
  
        foreach ( array_keys( $sprefs ) as $type ) {
 -              $parts = explode( '/', $type );
 -              if ( $parts[1] != '*' ) {
 +              $subType = explode( '/', $type )[1];
 +              if ( $subType != '*' ) {
                        $ckey = mimeTypeMatch( $type, $cprefs );
                        if ( $ckey ) {
                                $combine[$type] = $sprefs[$type] * $cprefs[$ckey];
        }
  
        foreach ( array_keys( $cprefs ) as $type ) {
 -              $parts = explode( '/', $type );
 -              if ( $parts[1] != '*' && !array_key_exists( $type, $sprefs ) ) {
 +              $subType = explode( '/', $type )[1];
 +              if ( $subType != '*' && !array_key_exists( $type, $sprefs ) ) {
                        $skey = mimeTypeMatch( $type, $sprefs );
                        if ( $skey ) {
                                $combine[$type] = $sprefs[$skey] * $cprefs[$type];