Move wfIncrStats() near other debugging functions
This commit is contained in:
parent
a4a0928072
commit
72cafa3c8d
1 changed files with 51 additions and 51 deletions
|
|
@ -1200,6 +1200,57 @@ function wfLogProfilingData() {
|
|||
wfErrorLog( $log . $profiler->getOutput(), $wgDebugLogFile );
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment a statistics counter
|
||||
*
|
||||
* @param $key String
|
||||
* @param $count Int
|
||||
*/
|
||||
function wfIncrStats( $key, $count = 1 ) {
|
||||
global $wgStatsMethod;
|
||||
|
||||
$count = intval( $count );
|
||||
|
||||
if( $wgStatsMethod == 'udp' ) {
|
||||
global $wgUDPProfilerHost, $wgUDPProfilerPort, $wgDBname, $wgAggregateStatsID;
|
||||
static $socket;
|
||||
|
||||
$id = $wgAggregateStatsID !== false ? $wgAggregateStatsID : $wgDBname;
|
||||
|
||||
if ( !$socket ) {
|
||||
$socket = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP );
|
||||
$statline = "stats/{$id} - 1 1 1 1 1 -total\n";
|
||||
socket_sendto(
|
||||
$socket,
|
||||
$statline,
|
||||
strlen( $statline ),
|
||||
0,
|
||||
$wgUDPProfilerHost,
|
||||
$wgUDPProfilerPort
|
||||
);
|
||||
}
|
||||
$statline = "stats/{$id} - {$count} 1 1 1 1 {$key}\n";
|
||||
wfSuppressWarnings();
|
||||
socket_sendto(
|
||||
$socket,
|
||||
$statline,
|
||||
strlen( $statline ),
|
||||
0,
|
||||
$wgUDPProfilerHost,
|
||||
$wgUDPProfilerPort
|
||||
);
|
||||
wfRestoreWarnings();
|
||||
} elseif( $wgStatsMethod == 'cache' ) {
|
||||
global $wgMemc;
|
||||
$key = wfMemcKey( 'stats', $key );
|
||||
if ( is_null( $wgMemc->incr( $key, $count ) ) ) {
|
||||
$wgMemc->add( $key, $count );
|
||||
}
|
||||
} else {
|
||||
// Disabled
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the wiki read-only lock file is present. This can be used to lock
|
||||
* off editing functions, but doesn't guarantee that the database will not be
|
||||
|
|
@ -2562,57 +2613,6 @@ function wfMkdirParents( $dir, $mode = null, $caller = null ) {
|
|||
return $ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment a statistics counter
|
||||
*
|
||||
* @param $key String
|
||||
* @param $count Int
|
||||
*/
|
||||
function wfIncrStats( $key, $count = 1 ) {
|
||||
global $wgStatsMethod;
|
||||
|
||||
$count = intval( $count );
|
||||
|
||||
if( $wgStatsMethod == 'udp' ) {
|
||||
global $wgUDPProfilerHost, $wgUDPProfilerPort, $wgDBname, $wgAggregateStatsID;
|
||||
static $socket;
|
||||
|
||||
$id = $wgAggregateStatsID !== false ? $wgAggregateStatsID : $wgDBname;
|
||||
|
||||
if ( !$socket ) {
|
||||
$socket = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP );
|
||||
$statline = "stats/{$id} - 1 1 1 1 1 -total\n";
|
||||
socket_sendto(
|
||||
$socket,
|
||||
$statline,
|
||||
strlen( $statline ),
|
||||
0,
|
||||
$wgUDPProfilerHost,
|
||||
$wgUDPProfilerPort
|
||||
);
|
||||
}
|
||||
$statline = "stats/{$id} - {$count} 1 1 1 1 {$key}\n";
|
||||
wfSuppressWarnings();
|
||||
socket_sendto(
|
||||
$socket,
|
||||
$statline,
|
||||
strlen( $statline ),
|
||||
0,
|
||||
$wgUDPProfilerHost,
|
||||
$wgUDPProfilerPort
|
||||
);
|
||||
wfRestoreWarnings();
|
||||
} elseif( $wgStatsMethod == 'cache' ) {
|
||||
global $wgMemc;
|
||||
$key = wfMemcKey( 'stats', $key );
|
||||
if ( is_null( $wgMemc->incr( $key, $count ) ) ) {
|
||||
$wgMemc->add( $key, $count );
|
||||
}
|
||||
} else {
|
||||
// Disabled
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $nr Mixed: the number to format
|
||||
* @param $acc Integer: the number of digits after the decimal point, default 2
|
||||
|
|
|
|||
Loading…
Reference in a new issue