dispatchUser() should use a 302 http status code
[lhc/web/wiklou.git] / includes / deferred / SiteStatsUpdate.php
index 2f882b8..7cb2950 100644 (file)
@@ -66,6 +66,12 @@ class SiteStatsUpdate implements DeferrableUpdate, MergeableUpdate {
        public static function factory( array $deltas ) {
                $update = new self( 0, 0, 0 );
 
+               foreach ( $deltas as $name => $unused ) {
+                       if ( !in_array( $name, self::$counters ) ) { // T187585
+                               throw new UnexpectedValueException( __METHOD__ . ": no field called '$name'" );
+                       }
+               }
+
                foreach ( self::$counters as $field ) {
                        if ( isset( $deltas[$field] ) && $deltas[$field] ) {
                                $update->$field = $deltas[$field];
@@ -148,18 +154,21 @@ class SiteStatsUpdate implements DeferrableUpdate, MergeableUpdate {
                $dbr = $services->getDBLoadBalancer()->getConnection( DB_REPLICA, '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.
+               $rcQuery = RecentChange::getQueryInfo();
                $activeUsers = $dbr->selectField(
-                       'recentchanges',
-                       'COUNT( DISTINCT rc_user_text )',
+                       $rcQuery['tables'],
+                       'COUNT( DISTINCT ' . $rcQuery['fields']['rc_user_text'] . ' )',
                        [
                                'rc_type != ' . $dbr->addQuotes( RC_EXTERNAL ), // Exclude external (Wikidata)
-                               'rc_user != 0',
+                               ActorMigration::newMigration()->isNotAnon( $rcQuery['fields']['rc_user'] ),
                                'rc_bot' => 0,
                                'rc_log_type != ' . $dbr->addQuotes( 'newusers' ) . ' OR rc_log_type IS NULL',
                                'rc_timestamp >= ' . $dbr->addQuotes(
                                        $dbr->timestamp( time() - $config->get( 'ActiveUserDays' ) * 24 * 3600 ) ),
                        ],
-                       __METHOD__
+                       __METHOD__,
+                       [],
+                       $rcQuery['joins']
                );
                $dbw->update(
                        'site_stats',