Niharika29 has uploaded a new change for review. https://gerrit.wikimedia.org/r/316375
Change subject: [WIP] Populate local and global ids in localuser table ...................................................................... [WIP] Populate local and global ids in localuser table Bug: T142503 Change-Id: I3b556476ae7210ae244c400ddd057e461ac869fa --- A maintenance/populateLocalAndGlobalIds.php 1 file changed, 46 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth refs/changes/75/316375/1 diff --git a/maintenance/populateLocalAndGlobalIds.php b/maintenance/populateLocalAndGlobalIds.php new file mode 100644 index 0000000..7a47cc9 --- /dev/null +++ b/maintenance/populateLocalAndGlobalIds.php @@ -0,0 +1,46 @@ +<?php +$IP = getenv( 'MW_INSTALL_PATH' ); +if ( $IP === false ) { + $IP = __DIR__ . '/../../..'; +} +require_once( "$IP/maintenance/Maintenance.php" ); + +class PopulateLocalAndGlobalIds extends Maintenance { + + public function __construct() { + parent::__construct(); + $this->mDescription = "Populate the localuser.lu_local_id and localuser.lu_global_id fields"; + $this->setBatchSize( 100 ); + } + + public function execute() { + $this->output( "Populating lu_local_id field...\n" ); + $dbr = CentralAuthUtils::getCentralSlaveDB(); + $dbw = CentralAuthUtils::getCentralDB(); + // TODO:Remove BRI stuff and do normal batching like other maintenance scripts + $iterator = new BatchRowIterator( + $dbr, + 'localuser', + ['lu_wiki', 'lu_name'], + $this->mBatchSize + ); + $processed = 0; + foreach ( $iterator as $batch ) { + foreach ( $batch as $row ) { + $lName = $row->lu_name; + $lWiki = $row->lu_wiki; + $dbr = wfGetDB( DB_SLAVE, [], $lWiki ); + // TODO: Space around [] + $lId = $dbr->selectField( 'user', 'user_id', ['user_name' => $lName] ); + $result = $dbw->update( 'localuser', ['lu_local_id' => $lId], ['lu_name' => $lName, 'lu_wiki' => $lWiki] ); + if ( !$result ) { + $this->output( "Update failed for user $lName for wiki $lWiki" ); + } + $processed += $dbw->affectedRows(); + } + $this->output( "Updated $processed records.\n" ); + } + $this->output( "Done.\n" ); + } +} + -- To view, visit https://gerrit.wikimedia.org/r/316375 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3b556476ae7210ae244c400ddd057e461ac869fa Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/CentralAuth Gerrit-Branch: master Gerrit-Owner: Niharika29 <nihar...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits