From c1f9b1f7b1b77776192048005dcc66dcf3df2bfb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 27 Dec 2014 15:41:37 +0100 Subject: Update to MediaWiki 1.24.1 --- includes/StatCounter.php | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'includes/StatCounter.php') diff --git a/includes/StatCounter.php b/includes/StatCounter.php index 1373f3d5..5fc8f2f5 100644 --- a/includes/StatCounter.php +++ b/includes/StatCounter.php @@ -36,10 +36,15 @@ * @ingroup StatCounter */ class StatCounter { - /** @var Array */ + /** @var array */ protected $deltas = array(); // (key => count) - protected function __construct() {} + /** @var Config */ + protected $config; + + protected function __construct( Config $config ) { + $this->config = $config; + } /** * @return StatCounter @@ -47,7 +52,9 @@ class StatCounter { public static function singleton() { static $instance = null; if ( !$instance ) { - $instance = new self(); + $instance = new self( + ConfigFactory::getDefaultInstance()->makeConfig( 'main' ) + ); } return $instance; } @@ -56,7 +63,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 ) { @@ -73,12 +80,11 @@ class StatCounter { * @return void */ public function flush() { - global $wgStatsMethod; - + $statsMethod = $this->config->get( 'StatsMethod' ); $deltas = array_filter( $this->deltas ); // remove 0 valued entries - if ( $wgStatsMethod === 'udp' ) { + if ( $statsMethod === 'udp' ) { $this->sendDeltasUDP( $deltas ); - } elseif ( $wgStatsMethod === 'cache' ) { + } elseif ( $statsMethod === 'cache' ) { $this->sendDeltasMemc( $deltas ); } else { // disabled @@ -91,14 +97,12 @@ class StatCounter { * @return void */ protected function sendDeltasUDP( array $deltas ) { - global $wgUDPProfilerHost, $wgUDPProfilerPort, $wgAggregateStatsID, - $wgStatsFormatString; - - $id = strlen( $wgAggregateStatsID ) ? $wgAggregateStatsID : wfWikiID(); + $aggregateStatsID = $this->config->get( 'AggregateStatsID' ); + $id = strlen( $aggregateStatsID ) ? $aggregateStatsID : wfWikiID(); $lines = array(); foreach ( $deltas as $key => $count ) { - $lines[] = sprintf( $wgStatsFormatString, $id, $count, $key ); + $lines[] = sprintf( $this->config->get( 'StatsFormatString' ), $id, $count, $key ); } if ( count( $lines ) ) { @@ -125,8 +129,8 @@ class StatCounter { $packet, strlen( $packet ), 0, - $wgUDPProfilerHost, - $wgUDPProfilerPort + $this->config->get( 'UDPProfilerHost' ), + $this->config->get( 'UDPProfilerPort' ) ); wfRestoreWarnings(); } -- cgit v1.2.3-54-g00ecf