X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fdeferred%2FSiteStatsUpdate.php;h=7cb2950942cb16d8c0acd603df89bd4794fd94cb;hb=b703c2408e649285bb363133b548fa1c45978a0b;hp=ad1f172460f0b765110a73989df1ec1edd97b906;hpb=c2adecb31b16a36efdb509a575533c7f103a0576;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/deferred/SiteStatsUpdate.php b/includes/deferred/SiteStatsUpdate.php index ad1f172460..7cb2950942 100644 --- a/includes/deferred/SiteStatsUpdate.php +++ b/includes/deferred/SiteStatsUpdate.php @@ -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]; @@ -101,9 +107,7 @@ class SiteStatsUpdate implements DeferrableUpdate, MergeableUpdate { $pd = []; if ( $config->get( 'SiteStatsAsyncFactor' ) ) { // Lock the table so we don't have double DB/memcached updates - if ( !$dbw->lockIsFree( $lockKey, __METHOD__ ) - || !$dbw->lock( $lockKey, __METHOD__, 1 ) // 1 sec timeout - ) { + if ( !$dbw->lock( $lockKey, __METHOD__, 0 ) ) { $this->doUpdatePendingDeltas(); return; @@ -150,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',