From 72cafa3c8d8aad6ac8a516ff2209fc175867d827 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Wed, 15 Feb 2012 16:17:02 +0000 Subject: [PATCH] Move wfIncrStats() near other debugging functions --- includes/GlobalFunctions.php | 102 +++++++++++++++++------------------ 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 7bddf835fe..5dbcbb103f 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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 -- 2.20.1