Page MenuHomePhabricator

Create a BlockRestrictionStoreFactory in order to make BlockRestrictionStore a proper cross-wiki store
Closed, ResolvedPublic

Description

Blocks can be issued cross-wiki. Thus BlockRestrictionStore should become a proper cross-wiki store by injecting the correct LoadBalancer into it. A new BlockRestrictionStoreFactory service should be created for doing so.

A LBFactory should be injected into BlockRestrictionStoreFactory which then fetches and injects the correct LoadBalancer into a BlockRestrictionStore.

Currently if a cross-wiki block with restrictions is being created, the block is being stored in the foreign database, but the restrictions are being stored in the local one. This is definetly not wanted.

Event Timeline

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

[mediawiki/core@master] Introduce a BlockRestrictionStoreFactory

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

  1. At least loading of the restrictions 'support' cross-wiki, cause there's an $db parameter to loadByBlockId. Once RestrictionStore is properly cross-wiki, that parameter can be removed.
  1. This is an interesting one. Ideally BlockRestrictionStore shouldn't really be a public service - there should be no reason for external code to call it instead of interacting with blocks.

There's currently two direct usages of BlockRestrictionStore outside of blocks code:

  • CentralAuthUser::localUserData - this is just manually implementing cross-wiki block loading, and it should be replaced with proper support you're trying to implement.
  • WikibaseLexeme in a test is inserting the restrictions, but that's easily fixed by setting restrictions on a block before inserting the block instead of after.

All other usages are in core. The usages that are outside of the blocks namespace are mostly cause the code there is querying blocks table directly.

TLDR: I think BlockRestrictionStoreFactory should be @internal. It future when more block-related code is cleaned up, it should be an internal service that only block-related code can depend on.

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

[mediawiki/extensions/CentralAuth@master] Fetch correct BlockRestrictionStore

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

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

[mediawiki/core@master] Deprecate passing a db to BlockRestrictionStore::loadByBlockId()

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

Change 724475 merged by jenkins-bot:

[mediawiki/core@master] Introduce a BlockRestrictionStoreFactory

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

Change 726053 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@master] Fetch correct BlockRestrictionStore

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

Change 754579 merged by jenkins-bot:

[mediawiki/core@master] Deprecate passing a db to BlockRestrictionStore::loadByBlockId()

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

Making BlockRestrictionStoreFactory @internal can be done in some follow-up.

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

[mediawiki/core@master] Don't allow passing a db to BlockRestrictionStore::loadByBlockId()

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

Change 772915 merged by jenkins-bot:

[mediawiki/core@master] Don't allow passing a db to BlockRestrictionStore::loadByBlockId()

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