Page MenuHomePhabricator

Add a column to store central ID in globalblocks and global_block_whitelist tables
Closed, ResolvedPublic2 Estimated Story Points

Description

To allow T17294 to be implemented, the existing database table globalblocks (and potentially global_block_whitelist too) need to be able to store the central ID associated with the target of the block.

This will be 0 when the target of the block is an IP and will be set to a value other than 0 when the target of the block is a user.

This is split from T17294 to make it easier to review the changes needed for T17294 and allow the database migration to occur on WMF wikis ahead of the review for the rest of the code.

QA Results - VCS

Event Timeline

Dreamy_Jazz renamed this task from Add column to store central ID in globalblocks and global_block_whitelist tables to Add a column to store central ID in globalblocks and global_block_whitelist tables.Feb 7 2024, 2:58 PM

Note: Central ID is a core MediaWiki concept (see https://www.mediawiki.org/wiki/Manual:Central_ID). Therefore we should not require CentralAuth to get the Central ID, and global blocks will still work if the wiki farm uses shared user table instead of CentralAuth.

Note: Central ID is a core MediaWiki concept (see https://www.mediawiki.org/wiki/Manual:Central_ID). Therefore we should not require CentralAuth to get the Central ID, and global blocks will still work if the wiki farm uses shared user table instead of CentralAuth.

Thanks. I agree with this and I intend to allow non-CentralAuth based installations to use this column / feature.

Change 998470 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[mediawiki/extensions/GlobalBlocking@master] Add central ID column to the global blocking tables

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

Change 998470 merged by jenkins-bot:

[mediawiki/extensions/GlobalBlocking@master] Add central ID column for the target of blocks in DB tables

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

Suggested QA steps for a local wiki using SQLite:

  1. Install the GlobalBlocking extension
  2. Run ./maintenance/run update.php
  3. Open up your DB and run .tables. Verify the output of this command includes the tables globalblocks and global_block_whitelist.
  4. Run .schema globalblocks and verify that the output looks like the following, making sure that a column named gb_target_central_id is present and that it has an index also called gb_target_central_id.
CREATE TABLE IF NOT EXISTS "globalblocks" (
 gb_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
 gb_address VARCHAR(255) NOT NULL,
 gb_target_central_id INTEGER UNSIGNED DEFAULT 0 NOT NULL,
 gb_by VARCHAR(255) DEFAULT '' NOT NULL,
 gb_by_central_id INTEGER UNSIGNED NOT NULL,
 gb_by_wiki BLOB NOT NULL,
 gb_reason BLOB NOT NULL,
 gb_timestamp BLOB NOT NULL,
 gb_anon_only SMALLINT DEFAULT 0 NOT NULL,
 gb_expiry BLOB NOT NULL,
 gb_range_start BLOB NOT NULL,
 gb_range_end BLOB NOT NULL
 );
CREATE UNIQUE INDEX gb_address ON "globalblocks" (gb_address, gb_anon_only)
;
CREATE INDEX gb_target_central_id ON "globalblocks" (gb_target_central_id)
;
CREATE INDEX gb_range ON "globalblocks" (gb_range_start, gb_range_end)
;
CREATE INDEX gb_timestamp ON "globalblocks" (gb_timestamp)
;
CREATE INDEX gb_expiry ON "globalblocks" (gb_expiry)
;
  1. Run .schema global_block_whitelist. Verify that the output looks like the following, making sure that a column named gbw_target_central_id exists in the table.
CREATE TABLE IF NOT EXISTS "global_block_whitelist" (
 gbw_id INTEGER NOT NULL,
 gbw_address BLOB NOT NULL,
 gbw_target_central_id INTEGER UNSIGNED DEFAULT 0 NOT NULL,
 gbw_by INTEGER NOT NULL,
 gbw_by_text BLOB NOT NULL,
 gbw_reason BLOB NOT NULL,
 gbw_expiry BLOB NOT NULL,
 PRIMARY KEY(gbw_id)
 );
CREATE INDEX gbw_by ON "global_block_whitelist" (gbw_by)
;

@Dreamy_Jazz gb_target_central_id is present for column name and index under globalblocks. Also gbw_target_central_id is present for the column under global_block_whitelist. I will move this to Done. Thanks for all your work and steps as usual!

Status: ✅PASS
Environment: Visual Studio Code
OS: macOS Sonoma 14.2.1
Browser: Chrome 121
Skins. N/A
Device: MBA M2
Emulated Device:: n/a
Test Links:
N/A

✅AC1: https://phabricator.wikimedia.org/T356876

2024-02-08_11-44-32.png (799×1 px, 468 KB)