X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fcache%2FUserCache.php;h=cb6857121e7c62514e5c41ab76b3b809dfb5dcfc;hp=5c752926283032726f70dc0fbbf0df558267368f;hb=a2c8c2969420a0f150c03f76e3a0bf9028fcda43;hpb=86448ece43db70f21d591b7d0ce52447664a2600 diff --git a/includes/cache/UserCache.php b/includes/cache/UserCache.php index 5c75292628..cb6857121e 100644 --- a/includes/cache/UserCache.php +++ b/includes/cache/UserCache.php @@ -80,6 +80,8 @@ class UserCache { * @param string $caller The calling method */ public function doQuery( array $userIds, $options = [], $caller = '' ) { + global $wgActorTableSchemaMigrationStage; + $usersToCheck = []; $usersToQuery = []; @@ -100,21 +102,34 @@ class UserCache { // Lookup basic info for users not yet loaded... if ( count( $usersToQuery ) ) { $dbr = wfGetDB( DB_REPLICA ); - $table = [ 'user' ]; + $tables = [ 'user' ]; $conds = [ 'user_id' => $usersToQuery ]; $fields = [ 'user_name', 'user_real_name', 'user_registration', 'user_id' ]; + $joinConds = []; + + if ( $wgActorTableSchemaMigrationStage > MIGRATION_OLD ) { + $tables[] = 'actor'; + $fields[] = 'actor_id'; + $joinConds['actor'] = [ + $wgActorTableSchemaMigrationStage === MIGRATION_NEW ? 'JOIN' : 'LEFT JOIN', + [ 'actor_user = user_id' ] + ]; + } $comment = __METHOD__; if ( strval( $caller ) !== '' ) { $comment .= "/$caller"; } - $res = $dbr->select( $table, $fields, $conds, $comment ); + $res = $dbr->select( $tables, $fields, $conds, $comment, [], $joinConds ); foreach ( $res as $row ) { // load each user into cache $userId = (int)$row->user_id; $this->cache[$userId]['name'] = $row->user_name; $this->cache[$userId]['real_name'] = $row->user_real_name; $this->cache[$userId]['registration'] = $row->user_registration; + if ( $wgActorTableSchemaMigrationStage > MIGRATION_OLD ) { + $this->cache[$userId]['actor'] = $row->actor_id; + } $usersToCheck[$userId] = $row->user_name; } }