From 6542746e6c18a19ab5937cb237aae72f0067dd33 Mon Sep 17 00:00:00 2001 From: Ori Livneh Date: Thu, 28 May 2015 17:55:17 -0700 Subject: [PATCH] Update context stats in SiteStatsUpdate In addition to updating the database / memcached, make SiteStatsUpdate also update the context stats object with the deltas it is processing. Change-Id: Icc12c07ab4233e1105a402b80d290bdb64df6ea7 --- includes/deferred/SiteStatsUpdate.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/includes/deferred/SiteStatsUpdate.php b/includes/deferred/SiteStatsUpdate.php index 3c7723810d..ae75a7549c 100644 --- a/includes/deferred/SiteStatsUpdate.php +++ b/includes/deferred/SiteStatsUpdate.php @@ -65,6 +65,8 @@ class SiteStatsUpdate implements DeferrableUpdate { public function doUpdate() { global $wgSiteStatsAsyncFactor; + $this->doUpdateContextStats(); + $rate = $wgSiteStatsAsyncFactor; // convenience // If set to do so, only do actual DB updates 1 every $rate times. // The other times, just update "pending delta" values in memcached. @@ -153,6 +155,16 @@ class SiteStatsUpdate implements DeferrableUpdate { return $activeUsers; } + protected function doUpdateContextStats() { + $stats = RequestContext::getMain()->getStats(); + foreach ( array( 'edits', 'articles', 'pages', 'users', 'images' ) as $type ) { + $delta = $this->$type; + if ( $delta !== 0 ) { + $stats->updateCount( "site.$type", $delta ); + } + } + } + protected function doUpdatePendingDeltas() { $this->adjustPending( 'ss_total_edits', $this->edits ); $this->adjustPending( 'ss_good_articles', $this->articles ); -- 2.20.1