Merge "Correctly use $wgFeedLimit in page history feed"
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index 78fcb8b..e71e80c 100644 (file)
@@ -130,14 +130,16 @@ function wfArrayDiff2_cmp( $a, $b ) {
 
 /**
  * Array lookup
- * Returns an array where the values in the first array are replaced by the
- * values in the second array with the corresponding keys
+ * Returns an array where the values in array $b are replaced by the
+ * values in array $a with the corresponding keys
  *
+ * @deprecated since 1.22; use array_intersect_key()
  * @param $a Array
  * @param $b Array
  * @return array
  */
 function wfArrayLookup( $a, $b ) {
+       wfDeprecated( __FUNCTION__, '1.22' );
        return array_flip( array_intersect( array_flip( $a ), array_keys( $b ) ) );
 }
 
@@ -163,11 +165,13 @@ function wfAppendToArrayIfNotDefault( $key, $value, $default, &$changed ) {
  * Backwards array plus for people who haven't bothered to read the PHP manual
  * XXX: will not darn your socks for you.
  *
+ * @deprecated since 1.22; use array_replace()
  * @param $array1 Array
  * @param [$array2, [...]] Arrays
  * @return Array
  */
 function wfArrayMerge( $array1/* ... */ ) {
+       wfDeprecated( __FUNCTION__, '1.22' );
        $args = func_get_args();
        $args = array_reverse( $args, true );
        $out = array();
@@ -1001,7 +1005,7 @@ function wfDebugLog( $logGroup, $text, $public = true ) {
                        wfErrorLog( "$time $host $wiki: $text", $wgDebugLogGroups[$logGroup] );
                }
        } elseif ( $public === true ) {
-               wfDebug( "[$logGroup] $text", true );
+               wfDebug( "[$logGroup] $text", false );
        }
 }
 
@@ -2024,9 +2028,11 @@ function wfEscapeWikiText( $text ) {
 
 /**
  * Get the current unix timestamp with microseconds.  Useful for profiling
+ * @deprecated since 1.22; call microtime() directly
  * @return Float
  */
 function wfTime() {
+       wfDeprecated( __FUNCTION__, '1.22' );
        return microtime( true );
 }
 
@@ -2593,11 +2599,11 @@ function in_string( $needle, $str, $insensitive = false ) {
  * @return Bool
  */
 function wfIniGetBool( $setting ) {
-       $val = ini_get( $setting );
+       $val = strtolower( ini_get( $setting ) );
        // 'on' and 'true' can't have whitespace around them, but '1' can.
-       return strtolower( $val ) == 'on'
-               || strtolower( $val ) == 'true'
-               || strtolower( $val ) == 'yes'
+       return $val == 'on'
+               || $val == 'true'
+               || $val == 'yes'
                || preg_match( "/^\s*[+-]?0*[1-9]/", $val ); // approx C atoi() function
 }
 
@@ -3750,22 +3756,17 @@ function wfBCP47( $code ) {
        $codeSegment = explode( '-', $code );
        $codeBCP = array();
        foreach ( $codeSegment as $segNo => $seg ) {
-               if ( count( $codeSegment ) > 0 ) {
-                       // when previous segment is x, it is a private segment and should be lc
-                       if ( $segNo > 0 && strtolower( $codeSegment[( $segNo - 1 )] ) == 'x' ) {
-                               $codeBCP[$segNo] = strtolower( $seg );
-                       // ISO 3166 country code
-                       } elseif ( ( strlen( $seg ) == 2 ) && ( $segNo > 0 ) ) {
-                               $codeBCP[$segNo] = strtoupper( $seg );
-                       // ISO 15924 script code
-                       } elseif ( ( strlen( $seg ) == 4 ) && ( $segNo > 0 ) ) {
-                               $codeBCP[$segNo] = ucfirst( strtolower( $seg ) );
-                       // Use lowercase for other cases
-                       } else {
-                               $codeBCP[$segNo] = strtolower( $seg );
-                       }
+               // when previous segment is x, it is a private segment and should be lc
+               if ( $segNo > 0 && strtolower( $codeSegment[( $segNo - 1 )] ) == 'x' ) {
+                       $codeBCP[$segNo] = strtolower( $seg );
+               // ISO 3166 country code
+               } elseif ( ( strlen( $seg ) == 2 ) && ( $segNo > 0 ) ) {
+                       $codeBCP[$segNo] = strtoupper( $seg );
+               // ISO 15924 script code
+               } elseif ( ( strlen( $seg ) == 4 ) && ( $segNo > 0 ) ) {
+                       $codeBCP[$segNo] = ucfirst( strtolower( $seg ) );
+               // Use lowercase for other cases
                } else {
-               // Use lowercase for single segment
                        $codeBCP[$segNo] = strtolower( $seg );
                }
        }