Page MenuHomePhabricator

Create global accounts for users where lu_global_id is null and only one row for a username
Open, Needs TriagePublic

Description

We have 3913 accounts where lu_global_id is null, and only 5 usernames have more than one row.

We should create globaluser rows for these accounts where there's only one row.

migrateAccount.php can mostly do this, and attachbroken would get round the empty email etc...

wikiadmin2023@10.192.48.205(centralauth)> select lu_name, count(*) as cnt, group_concat(lu_wiki) from localuser where lu_global_id is null group by lu_name having cnt > 1;
+------------------------------+-----+-----------------------+
| lu_name                      | cnt | group_concat(lu_wiki) |
+------------------------------+-----+-----------------------+
| Besir.arifi                  |   2 | mkwiki,sqwiki         |
| Fabriciotg                   |   2 | cawiki,eswiki         |
| Mazzikamadura                |   2 | enwiki,idwiki         |
| SELFEDITION                  |   2 | enwiki,svwiki         |
| Trần Nguyễn Hạo Thiên        |   2 | enwiki,viwiki         |
+------------------------------+-----+-----------------------+

What's the best way to create CentralAuth accounts, and therefore globaluser rows for these users?


See also: T388983: localuser rows where lu_global_id IS NOT NULL AND lu_local_id IS NULL not fixed by populateLocalAndGlobalIds.php, T303590: Fix localuser rows with lu_local_id or lu_global_id that aren't correctly set

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

I'm not really familiar with this part of the code but it seems like migrateAccount.php --safe --auto would work, assuming localuser data is sane and the user really isn't present in globaluser.

It looks to me like attachbroken will only kick in if there is already a global account for the username (there is an entry in globaluser with gu_name being the same as the specified user name). I could be misreading the script though.

https://meta.wikimedia.org/wiki/Special:CentralAuth/Tanglei2341 says no global account

| Tanglei2341                                                     |         NULL |     1452769 | zhwiki        |

https://zh.wikipedia.org/w/api.php?action=query&list=users&ususers=Tanglei2341&usprop=groups|editcount|gender

{
    "batchcomplete": "",
    "query": {
        "users": [
            {
                "userid": 1452769,
                "name": "Tanglei2341",
                "editcount": 0,
                "groups": [
                    "*",
                    "user"
                ],
                "gender": "unknown"
            }
        ]
    }
}
reedy@deploy2002:~$ mwscript extensions/CentralAuth/maintenance/migrateAccount.php --wiki=metawiki --safe --auto --username=Tanglei2341
CentralAuth account migration for: Tanglei2341
ERROR: No local accounts found for: Tanglei2341
2025-12-05 00:38:01 processed 1 usernames (7.9/sec), 0 (0.0%) fully migrated, 0 (0.0%) partially migrated
done.
	private function doListUnattached() {
		$databaseManager = CentralAuthServices::getDatabaseManager();
		// Make sure lazy-loading in listUnattached() works, as we
		// may need to *switch* to using the primary DB for this query
		$db = $databaseManager->centralLBHasRecentPrimaryChanges()
			? $databaseManager->getCentralPrimaryDB()
			: $this->getSafeReadDB();

		$result = $db->newSelectQueryBuilder()
			->select( 'ln_wiki' )
			->from( 'localnames' )
			->leftJoin( 'localuser', null, [ 'ln_wiki=lu_wiki', 'ln_name=lu_name' ] )
			->where( [ 'ln_name' => $this->mName, 'lu_name' => null ] )
			->caller( __METHOD__ )
			->fetchFieldValues();

		$wikis = [];
		foreach ( $result as $wiki ) {
			if ( !WikiMap::getWiki( $wiki ) ) {
				$this->logger->warning( __METHOD__ . ': invalid wiki in localnames: ' . $wiki );
				continue;
			}

			$wikis[] = $wiki;
		}

		return $wikis;
	}

^ So it is looking for localnames that don't have a corresponding localuser row? And because it does... We get no results?