}
}
+/**
+ * Send a line giving PHP memory usage.
+ * @param $exact Bool : print exact values instead of kilobytes (default: false)
+ */
+function wfDebugMem( $exact = false ) {
+ $mem = memory_get_usage();
+ if( !$exact ) {
+ $mem = floor( $mem / 1024 ) . ' kilobytes';
+ } else {
+ $mem .= ' bytes';
+ }
+ wfDebug( "Memory usage: $mem\n" );
+}
+
/**
* Send a line to a supplementary debug log file, if configured, or main debug log if not.
* $wgDebugLogGroups[$logGroup] should be set to a filename to send to a separate log.
// Reset the 'Content-Encoding' field set by this handler
// so we can start fresh.
header( 'Content-Encoding:' );
+ break;
}
}
}
return $out;
}
-/**
- * Merge multiple arrays together.
- * On encountering duplicate keys, merge the two, but ONLY if they're arrays.
- * PHP's array_merge_recursive() merges ANY duplicate values into arrays,
- * which is not fun
- */
-function wfArrayDeepMerge( $array1/* ... */ ) {
- $out = $array1;
- for( $i=1; $i< func_num_args(); $i++ ) {
- foreach( func_get_arg( $i ) as $key => $value ) {
- if ( isset($out[$key]) && is_array($out[$key]) && is_array($value) ) {
- $out[$key] = wfArrayDeepMerge( $out[$key], $value );
- } elseif ( !isset($out[$key] || !$out[$key] ) {
- // Values that evaluate to true given precedence, for the primary purpose of merging permissions arrays.
- $out[$key] = $value;
- }
- }
- }
-
- return $out;
-}
-
/**
* Make a URL index, appropriate for the el_index field of externallinks.
*/