jenkins-bot has submitted this change and it was merged.
Change subject: Modify the populateLocalAndGlobalIds maintenance script to:
......................................................................
Modify the populateLocalAndGlobalIds maintenance script to:
* Exclude renames while populating records to avoid conflicts
* Run per wiki (using the foreachwiki shell script)
* Don't run if the wiki is non-SUL wiki
Change-Id: I7ed2c3880b92b0d8882c8a3cba2435945ad6142f
---
M maintenance/populateLocalAndGlobalIds.php
1 file changed, 29 insertions(+), 12 deletions(-)
Approvals:
Kaldari: Looks good to me, approved
Gergő Tisza: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/maintenance/populateLocalAndGlobalIds.php
b/maintenance/populateLocalAndGlobalIds.php
index 3fba4ab..0e2a756 100644
--- a/maintenance/populateLocalAndGlobalIds.php
+++ b/maintenance/populateLocalAndGlobalIds.php
@@ -14,18 +14,26 @@
}
public function execute() {
- global $wgLocalDatabases;
- $dbr = CentralAuthUtils::getCentralSlaveDB();
- $dbw = CentralAuthUtils::getCentralDB();
- foreach( $wgLocalDatabases as $wiki ) {
- // Temporarily skipping large wikis, 5 mil seems like a
safe number (skips en, meta, mediawiki & login wikis)
- $size = $dbr->estimateRowCount( 'localuser', '*', [
'lu_wiki' => $wiki ] );
- if ( $size > 5000000 ) {
- continue;
- }
+ if ( class_exists( 'CentralAuthUtils' ) ) {
+ $dbr = CentralAuthUtils::getCentralSlaveDB();
+ $dbw = CentralAuthUtils::getCentralDB();
$lastGlobalId = -1;
+
+ // Skip people in global rename queue
+ $wiki = wfWikiID();
+ $globalRenames = [];
+ $rows = $dbr->select(
+ 'renameuser_status',
+ 'ru_oldname'
+ );
+ foreach ( $rows as $row ) {
+ $globalRenames[] = $row->ru_oldname;
+ }
+
$lb = wfGetLB( $wiki );
$ldbr = $lb->getConnection( DB_SLAVE, [], $wiki );
+
+ $this->output( "Populating fields for wiki $wiki... \n"
);
do {
$rows = $dbr->select(
[ 'localuser', 'globaluser' ],
@@ -45,10 +53,13 @@
$globalUidToLocalName = [];
foreach ( $rows as $row ) {
+ if ( in_array( $row->lu_name,
$globalRenames ) ) {
+ $this->output( "User " .
$row->lu_name . " not migrated (pending rename)\n" );
+ continue;
+ }
$globalUidToLocalName[$row->gu_id] =
$row->lu_name;
}
if ( !$globalUidToLocalName ) {
- $this->output( "All users migrated;
Wiki: $wiki \n" );
continue;
}
@@ -61,6 +72,7 @@
foreach ( $localIds as $lid ) {
$localNameToUid[$lid->user_name] =
$lid->user_id;
}
+ $updated = 0;
foreach ( $globalUidToLocalName as $gid =>
$uname ) {
// Save progress so we know where to
start our next batch
$lastGlobalId = $gid;
@@ -74,14 +86,19 @@
);
if ( !$result ) {
$this->output( "Update failed
for global user $lastGlobalId for wiki $wiki \n" );
+ } else {
+ // Count number of records
actually updated
+ $updated++;
}
}
- $this->output( "Updated $numRows records. Last
user: $lastGlobalId; Wiki: $wiki \n" );
+ $this->output( "Updated $updated records. Last
user: $lastGlobalId; Wiki: $wiki \n" );
CentralAuthUtils::waitForSlaves();
} while ( $numRows >= $this->mBatchSize );
$lb->reuseConnection( $ldbr );
+ $this->output( "Completed $wiki \n" );
+ } else {
+ $this->error( "This script requires that the
CentralAuth extension is enabled. Please enable it and try again.", 1 );
}
- $this->output( "Done.\n" );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/324793
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7ed2c3880b92b0d8882c8a3cba2435945ad6142f
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: Niharika29 <[email protected]>
Gerrit-Reviewer: Gergő Tisza <[email protected]>
Gerrit-Reviewer: Kaldari <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: MarcoAurelio <[email protected]>
Gerrit-Reviewer: Niharika29 <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits