Prepare for CentralIdLookup returning UserIdentity

Needed-By: I67bf4f2442269b8aa1002868ede9a71a5ca43a84
Change-Id: I4c2170a25ea8b1cf5410a4648ebec66a3ab253f3
This commit is contained in:
Petr Pchelko 2021-06-24 12:21:49 -07:00
parent 590a7d502e
commit 64531785a6

View file

@ -1,5 +1,7 @@
<?php <?php
use MediaWiki\MediaWikiServices;
$IP = getenv( 'MW_INSTALL_PATH' ); $IP = getenv( 'MW_INSTALL_PATH' );
if ( $IP === false ) { if ( $IP === false ) {
$IP = __DIR__ . '/../../..'; $IP = __DIR__ . '/../../..';
@ -18,7 +20,7 @@ class BackfillUnreadWikis extends Maintenance {
public function execute() { public function execute() {
$dbFactory = MWEchoDbFactory::newFromDefault(); $dbFactory = MWEchoDbFactory::newFromDefault();
$lookup = CentralIdLookup::factory(); $lookup = MediaWikiServices::getInstance()->getCentralIdLookup();
$rebuild = $this->hasOption( 'rebuild' ); $rebuild = $this->hasOption( 'rebuild' );
if ( $rebuild ) { if ( $rebuild ) {
@ -41,10 +43,13 @@ class BackfillUnreadWikis extends Maintenance {
$iterator->setCaller( __METHOD__ ); $iterator->setCaller( __METHOD__ );
$processed = 0; $processed = 0;
$userFactory = MediaWikiServices::getInstance()->getUserFactory();
foreach ( $iterator as $batch ) { foreach ( $iterator as $batch ) {
foreach ( $batch as $row ) { foreach ( $batch as $row ) {
if ( $rebuild ) { if ( $rebuild ) {
$user = $lookup->localUserFromCentralId( $row->euw_user, CentralIdLookup::AUDIENCE_RAW ); $user = $userFactory->newFromUserIdentity(
$lookup->localUserFromCentralId( $row->euw_user, CentralIdLookup::AUDIENCE_RAW )
);
} else { } else {
$user = User::newFromRow( $row ); $user = User::newFromRow( $row );
} }