Page MenuHomePhabricator

Convert DatabaseBlock and AbstractBlock to UserIdentity, and make them cross-wiki aware.
Closed, ResolvedPublic

Description

Problem: CentralAuthUser calls DatabaseBlock::insert, passing a DB connection to another wiki. The User instance inside DatabaseBlock does not know about that DB, and may load data from the local DB, causing confusion. This was the root cause of T260485, which has a workaround in place.

Solution: DatabaseBlock and AbstractBlock should always use a string as the target and a UserIdentity (or Authority?) as the blocker. They should never create User instances.

NOTE: DatabaseBlock and AbstractBlock are designed to support "foreign" users (which are local actors referring to users on another wiki, using a prefixed user name). They do not properly support cross-wiki user instances.
NOTE: getBlocker() should return a UserIdentity instead of a User. This is a breaking change, but there is only one usage outside core, in the RegexBlock extension, which is trivial to fix.

Related Objects

Event Timeline

daniel triaged this task as High priority.Feb 15 2021, 8:05 PM
daniel updated the task description. (Show Details)

See also T266409 for other blocking-related code (there might be a need to change all of these together, although I haven't really investigated).

FYI: Both parent tasks I just added will be resolved together with this one, T284873 will only need T281972#7090252 to be reverted (currently deployed as a secpatch).

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

[mediawiki/core@master] Make Block objects aware of which wiki they belong to.

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

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

[mediawiki/extensions/CentralAuth@master] Set wiki parameter for cross-wiki suppressions

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

Change 738546 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@master] Set wiki parameter for cross-wiki suppressions

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

Change 723790 merged by jenkins-bot:

[mediawiki/core@master] Make Block objects aware of which wiki they belong to

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

Zabe closed this task as Resolved.EditedJan 17 2022, 11:27 PM

Blocks are using UserIdentity and are wikiaware now. There is still a lot to do until we properly support cross-wiki blocking, tracked at T291994: Properly support cross-wiki blocking.

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

[mediawiki/core@master] DatabaseBlock: fetch a database connection for the correct wiki

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

Change 755758 merged by jenkins-bot:

[mediawiki/core@master] DatabaseBlock: fetch a database connection for the correct wiki

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

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

[mediawiki/core@master] DatabaseBlock: assert the blocker to be from the correct wiki

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

Change 756129 merged by jenkins-bot:

[mediawiki/core@master] DatabaseBlock: assert the blocker to be from the correct wiki

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

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

[mediawiki/core@master] Deprecate accessing block ids cross-wiki

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

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

[mediawiki/core@master] Throw for mismatched wiki in AbstractBlock::getBy()

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

Change 806347 merged by jenkins-bot:

[mediawiki/core@master] Throw for mismatched wiki in AbstractBlock::getBy()

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