X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FStatCounter.php;h=a429c3675eeb774146fe76153beb198930098b01;hb=58e0f0bd236fddda02e177e17264357949507ef2;hp=23a4e2bf18bb50237636b5170d9cee7408095e6c;hpb=853f21b42e95b16c876c94245a5a4645dd982e93;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/StatCounter.php b/includes/StatCounter.php index 23a4e2bf18..a429c3675e 100644 --- a/includes/StatCounter.php +++ b/includes/StatCounter.php @@ -26,6 +26,7 @@ * * @file * @ingroup StatCounter + * @author Aaron Schulz */ /** @@ -35,7 +36,7 @@ * @ingroup StatCounter */ class StatCounter { - /** @var Array */ + /** @var array */ protected $deltas = array(); // (key => count) protected function __construct() {} @@ -55,7 +56,7 @@ class StatCounter { * Increment a key by delta $count * * @param string $key - * @param integer $count + * @param int $count * @return void */ public function incr( $key, $count = 1 ) { @@ -85,21 +86,25 @@ class StatCounter { $this->deltas = array(); } + /** + * @param array $deltas + * @return void + */ protected function sendDeltasUDP( array $deltas ) { - global $wgUDPProfilerHost, $wgUDPProfilerPort, $wgAggregateStatsID; + global $wgUDPProfilerHost, $wgUDPProfilerPort, $wgAggregateStatsID, + $wgStatsFormatString; $id = strlen( $wgAggregateStatsID ) ? $wgAggregateStatsID : wfWikiID(); $lines = array(); foreach ( $deltas as $key => $count ) { - $lines[] = "stats/{$id} - {$count} 1 1 1 1 {$key}\n"; + $lines[] = sprintf( $wgStatsFormatString, $id, $count, $key ); } if ( count( $lines ) ) { static $socket = null; if ( !$socket ) { $socket = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP ); - array_unshift( $lines, "stats/{$id} - 1 1 1 1 1 -total\n" ); } $packet = ''; $packets = array(); @@ -128,6 +133,10 @@ class StatCounter { } } + /** + * @param array $deltas + * @return void + */ protected function sendDeltasMemc( array $deltas ) { global $wgMemc;