Page MenuHomePhabricator

Migrate globalblocks table to use central ids instead of usernames
Open, Needs TriagePublic

Description

Currently the blocker is saved with their username in the database. We should migrate this to use central ids instead. This is also the proper fix of T298707: "InvalidArgumentException: Blocker must be a local user" from GlobalBlocking.

Event Timeline

Change 754584 had a related patch set uploaded (by Zabe; author: Zabe):

[mediawiki/extensions/GlobalBlocking@master] Add column for central blocker ids

https://gerrit.wikimedia.org/r/754584

Change 754584 merged by jenkins-bot:

[mediawiki/extensions/GlobalBlocking@master] Add column for central blocker ids

https://gerrit.wikimedia.org/r/754584

Change 759731 had a related patch set uploaded (by Zabe; author: Zabe):

[mediawiki/extensions/GlobalBlocking@master] Write central id to database when global blocks are issued

https://gerrit.wikimedia.org/r/759731

Change 760202 had a related patch set uploaded (by Majavah; author: Majavah):

[operations/mediawiki-config@master] Ensure GlobalBlocking is not loaded without CentralAuth

https://gerrit.wikimedia.org/r/760202

Change 760202 merged by jenkins-bot:

[operations/mediawiki-config@master] Ensure GlobalBlocking is not loaded without CentralAuth

https://gerrit.wikimedia.org/r/760202

Mentioned in SAL (#wikimedia-operations) [2022-02-07T12:31:18Z] <taavi@deploy1002> Synchronized wmf-config/CommonSettings.php: Config: [[gerrit:760202|Ensure GlobalBlocking is not loaded without CentralAuth (T299371)]] (1/2) (duration: 00m 48s)

Mentioned in SAL (#wikimedia-operations) [2022-02-07T12:32:12Z] <taavi@deploy1002> Synchronized wmf-config/InitialiseSettings.php: Config: [[gerrit:760202|Ensure GlobalBlocking is not loaded without CentralAuth (T299371)]] (2/2) (duration: 00m 48s)

Change 759731 merged by jenkins-bot:

[mediawiki/extensions/GlobalBlocking@master] Write central id to database when global blocks are issued

https://gerrit.wikimedia.org/r/759731

Change 762493 had a related patch set uploaded (by Zabe; author: Zabe):

[mediawiki/extensions/GlobalBlocking@master] maintenance: add a script for populating the gb_by_central_id column

https://gerrit.wikimedia.org/r/762493

Change 762493 merged by jenkins-bot:

[mediawiki/extensions/GlobalBlocking@master] maintenance: add a script for populating the gb_by_central_id column

https://gerrit.wikimedia.org/r/762493

Change 754584 merged by jenkins-bot:

[mediawiki/extensions/GlobalBlocking@master] Add column for central blocker ids

https://gerrit.wikimedia.org/r/754584

Yay for applying schema changes to the tables in the wikisdb, but ignoring the global one.

Wikimedia\Rdbms\DBQueryError from line 1606 of /var/www/wiki/mediawiki/core/includes/libs/rdbms/database/Database.php: Error 1054: Unknown column 'gb_by_central_id' in 'where clause' (10.x.x.x:3306)
Function: MediaWiki\Extension\GlobalBlocking\Maintenance\PopulateCentralId::doDbUpdates
Query: SELECT  gb_id,gb_by  FROM `globalblocks`    WHERE gb_by_central_id IS NULL AND gb_by_wiki = 'wikidb-mw_' AND (gb_id BETWEEN 0 AND 200)  

#0 /var/www/wiki/mediawiki/core/includes/libs/rdbms/database/Database.php(1590): Wikimedia\Rdbms\Database->getQueryException()
#1 /var/www/wiki/mediawiki/core/includes/libs/rdbms/database/Database.php(1564): Wikimedia\Rdbms\Database->getQueryExceptionAndLog()
#2 /var/www/wiki/mediawiki/core/includes/libs/rdbms/database/Database.php(1173): Wikimedia\Rdbms\Database->reportQueryError()
#3 /var/www/wiki/mediawiki/core/includes/libs/rdbms/database/Database.php(1810): Wikimedia\Rdbms\Database->query()
#4 /var/www/wiki/mediawiki/core/includes/libs/rdbms/database/DBConnRef.php(69): Wikimedia\Rdbms\Database->select()
#5 /var/www/wiki/mediawiki/core/includes/libs/rdbms/database/DBConnRef.php(319): Wikimedia\Rdbms\DBConnRef->__call()
#6 /var/www/wiki/mediawiki/extensions/GlobalBlocking/maintenance/PopulateCentralId.php(68): Wikimedia\Rdbms\DBConnRef->select()
#7 /var/www/wiki/mediawiki/core/maintenance/includes/LoggedUpdateMaintenance.php(45): MediaWiki\Extension\GlobalBlocking\Maintenance\PopulateCentralId->doDbUpdates()
#8 /var/www/wiki/mediawiki/core/maintenance/update.php(205): LoggedUpdateMaintenance->execute()
#9 /var/www/wiki/mediawiki/core/maintenance/doMaintenance.php(114): UpdateMediaWiki->execute()
#10 /var/www/wiki/mediawiki/core/maintenance/update.php(264): require_once('/var/www/wiki/m...')
#11 {main}

But from the update.php log...

...have gb_by_central_id field in globalblocks table.

If I look at wikidb.mw_globalblocks there is a gb_by_central_id column.

If I look at globalblocking.globalblocks there is not.

The latter is the default value for $wgGlobalBlockingDatabase.

Obviously I can fix it manually and apply the schema change patch to globalblocking.globalblocks...

Change 769146 had a related patch set uploaded (by Zabe; author: Zabe):

[mediawiki/extensions/GlobalBlocking@master] Also add gb_by_central_id to the global extension table

https://gerrit.wikimedia.org/r/769146

Change 779139 had a related patch set uploaded (by Zabe; author: Zabe):

[mediawiki/extensions/GlobalBlocking@master] Migrate to the usage of central ids

https://gerrit.wikimedia.org/r/779139