* array( array( 'x' ) ),
* array( array( 'x', '2' ) ),
* array( array( 'x' ) ),
- * array( array( 'y') )
+ * array( array( 'y' ) )
* );
* returns:
* array(
} else {
$prefix = sprintf( "%6.4f", microtime( true ) - $start );
}
-
- return $prefix . ' ';
+ $mem = sprintf( "%5.1fM", ( memory_get_usage( true ) / (1024*1024) ) );
+ return "$prefix $mem " ;
}
/**
if ( !$sock ) {
return;
}
- socket_sendto( $sock, $text, strlen( $text ), 0, $host, $port );
+
+ $len = strlen( $text );
+ $maxLen = socket_get_option( $sock, SOL_SOCKET, SO_SNDBUF );
+
+ if ( $len > $maxLen ) {
+ $len = $maxLen - 1;
+ }
+ socket_sendto( $sock, $text, $len, 0, $host, $port );
socket_close( $sock );
} else {
wfSuppressWarnings();
* a valid code create a language for that language, if
* it is a string but not a valid code then make a basic
* language object
- * - a boolean: if it's false then use the current users
- * language (as a fallback for the old parameter
- * functionality), or if it is true then use the wikis
+ * - a boolean: if it's false then use the global object for
+ * the current user's language (as a fallback for the old parameter
+ * functionality), or if it is true then use global object
+ * for the wiki's content language.
* @return Language object
*/
function wfGetLangObj( $langcode = false ) {
function wfNegotiateType( $cprefs, $sprefs ) {
$combine = array();
- foreach( array_keys($sprefs) as $type ) {
+ foreach( array_keys( $sprefs ) as $type ) {
$parts = explode( '/', $type );
if( $parts[1] != '*' ) {
$ckey = mimeTypeMatch( $type, $cprefs );
} else {
if ( !$suppressCount ) {
// E_DEPRECATED is undefined in PHP 5.2
- if( !defined( 'E_DEPRECATED' ) ){
+ if( !defined( 'E_DEPRECATED' ) ) {
define( 'E_DEPRECATED', 8192 );
}
$originalLevel = error_reporting( E_ALL & ~( E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_DEPRECATED ) );
# TS_POSTGRES
} elseif ( preg_match( '/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)\.*\d* GMT$/', $ts, $da ) ) {
# TS_POSTGRES
- } elseif (preg_match('/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)\.\d\d\d$/',$ts,$da)) {
+ } elseif (preg_match( '/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)\.\d\d\d$/', $ts, $da ) ) {
# TS_DB2
} elseif ( preg_match( '/^[ \t\r\n]*([A-Z][a-z]{2},[ \t\r\n]*)?' . # Day of week
'\d\d?[ \t\r\n]*[A-Z][a-z]{2}[ \t\r\n]*\d{2}(?:\d{2})?' . # dd Mon yyyy
* @return String
*/
function wfWikiID() {
- global $wgDBprefix, $wgDBname;
- if ( $wgDBprefix ) {
+ global $wgDBprefix, $wgDBname, $wgWikiID;
+ if ( $wgWikiID !== false ) {
+ return $wgWikiID;
+ } elseif ( $wgDBprefix ) {
return "$wgDBname-$wgDBprefix";
} else {
return $wgDBname;
*
* @param $wiki String
* @param $bits String
+ *
+ * @return array
*/
function wfSplitWikiID( $wiki ) {
$bits = explode( '-', $wiki, 2 );
* Throws a warning that $function is deprecated
*
* @param $function String
+ * @param $version String
* @return null
*/
-function wfDeprecated( $function ) {
+function wfDeprecated( $function, $version = false ) {
static $functionsWarned = array();
if ( !isset( $functionsWarned[$function] ) ) {
$functionsWarned[$function] = true;
- wfWarn( "Use of $function is deprecated.", 2 );
+ if ( $version ) {
+ global $wgDeprecationReleaseLimit;
+ if ( $wgDeprecationReleaseLimit ) {
+ # Strip -* off the end of $version so that branches can use the
+ # format #.##-branchname to avoid issues if the branch is merged into
+ # a version of MediaWiki later than what it was branched from
+ $comparableVersion = preg_replace( '/-.*$/', '', $version );
+ # If the comparableVersion is larger than our release limit then
+ # skip the warning message for the deprecation
+ if ( version_compare( $wgDeprecationReleaseLimit, $comparableVersion, '<' ) ) {
+ return;
+ }
+ }
+ wfWarn( "Use of $function was deprecated in $version.", 2 );
+ } else {
+ wfWarn( "Use of $function is deprecated.", 2 );
+ }
}
}
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') {
+ if( $segNo > 0 && strtolower( $codeSegment[( $segNo - 1 )] ) == 'x' ) {
$codeBCP[$segNo] = strtolower( $seg );
// ISO 3166 country code
} elseif ( ( strlen( $seg ) == 2 ) && ( $segNo > 0 ) ) {