Merge "Made ReplicatedBagOStuff wrapping the SQL class the default stash"
[lhc/web/wiklou.git] / includes / deferred / SiteStatsUpdate.php
index 97a17c3..ae75a75 100644 (file)
@@ -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.
@@ -128,7 +130,7 @@ class SiteStatsUpdate implements DeferrableUpdate {
         */
        public static function cacheUpdate( $dbw ) {
                global $wgActiveUserDays;
-               $dbr = wfGetDB( DB_SLAVE, array( 'SpecialStatistics', 'vslow' ) );
+               $dbr = wfGetDB( DB_SLAVE, 'vslow' );
                # Get non-bot users than did some recent action other than making accounts.
                # If account creation is included, the number gets inflated ~20+ fold on enwiki.
                $activeUsers = $dbr->selectField(
@@ -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 );