Skip to content

Commit

Permalink
Merge "specialpage: Preload edit count on ChangesListSpecialPage"
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Jun 20, 2024
2 parents 5898c71 + 910f50e commit 0fb7fe4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions includes/specialpage/ChangesListSpecialPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
use MediaWiki\Parser\Sanitizer;
use MediaWiki\ResourceLoader as RL;
use MediaWiki\User\TempUser\TempUserConfig;
use MediaWiki\User\UserArray;
use MediaWiki\User\UserIdentity;
use MediaWiki\User\UserIdentityUtils;
use MWExceptionHandler;
Expand Down Expand Up @@ -697,18 +698,27 @@ public function execute( $subpage ) {

$linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
$batch = $linkBatchFactory->newLinkBatch();
$userNames = [];
foreach ( $rows as $row ) {
$batch->add( NS_USER, $row->rc_user_text );
$batch->add( NS_USER_TALK, $row->rc_user_text );
$userNames[] = $row->rc_user_text;
$batch->add( $row->rc_namespace, $row->rc_title );
if ( $row->rc_source === RecentChange::SRC_LOG ) {
$formatter = LogFormatter::newFromRow( $row );
foreach ( $formatter->getPreloadTitles() as $title ) {
$batch->addObj( $title );
if ( $title->inNamespace( NS_USER ) || $title->inNamespace( NS_USER_TALK ) ) {
$userNames[] = $title->getText();
}
}
}
}
$batch->execute();
foreach ( UserArray::newFromNames( $userNames ) as $_ ) {
// Trigger UserEditTracker::setCachedUserEditCount via User::loadFromRow
// Preloads edit count for User::getExperienceLevel() and Linker::userToolLinks()
}

$this->setHeaders();
$this->outputHeader();
Expand Down

0 comments on commit 0fb7fe4

Please sign in to comment.