Page MenuHomePhabricator

Create RestrictionStore service
Open, NormalPublic

Description

The purpose of this task is to allow application logic to determine restrictions (protection) imposed on a page given only a PageIdentity, without the need to have a Title object. RestrictionStore is to replace the usage of Title::getRestrictions in PermissionManager (see T208768) and other application logic.

Methods to be factored into the new service class:

  • Title::loadRestrictions
  • Title::loadRestrictionsFromRows should probably just be removed.
  • Title::getRestrictions
  • Title::getAllRestrictions
  • Title::getRestrictionExpiry
  • Title::getTitleProtection
  • Title::isSemiProtected
  • Title::deleteTitleProtection
  • Title::isProtected
  • Title::isNamespaceProtected - though perhaps that could go into PermissionManager
  • Title::isCascadeProtected
  • Title::getCascadeProtectionSources
  • perhaps other methods dealing with restrictions in Title
  • finally, WikiPage::doUpdateRestrictions. This needs breaking up. At least the actual interaction with the page_restrictions should be done in PermissionManager. Insertion of the dummy revision should probably stay in WikiPagec for now.

The old methods should be deprecated but kept, delegating any calls to the new service.

Considerations:

  • RestrictionStore should bind to PageIdentity instead of Tilte, once PageIdentity identity becomes available (see T208776). Until then, taking a Title object as input is acceptable, but it must only be used to obtain the page ID or the title text and namespace.
  • RestrictionStore must not make use of the User class.

See also:
T219441: Introduce a BlockManager service for getting and combining the blocks that apply to a user/IP

Details

Related Gerrit Patches:

Event Timeline

daniel created this task.Mar 15 2019, 12:23 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 15 2019, 12:23 PM
daniel removed daniel as the assignee of this task.Mar 15 2019, 4:21 PM
CCicalese_WMF triaged this task as Normal priority.Mar 15 2019, 5:41 PM
Tgr added a subscriber: Tgr.Apr 9 2019, 3:46 PM
dmaza added a subscriber: dmaza.Apr 9 2019, 4:27 PM
Tgr added a comment.Apr 12 2019, 12:09 AM

PageIdentity refers to a page that exists; protecting non-existing pages is entirely meaningful. Also you need to deal with conterfactual state for permission checks. E.g. a permission check for moving a page into the MediaWiki namespace (which has a magic restriction) needs to check against the future state of the page. (This comes up elsewhere as well, e.g. permission checks for a content model change. Probably worth thinking about as a general issue.) So something like TitleValue seems more appropriate here.

The is* methods don't really belong to a storage layer class IMO.

PageIdentity refers to a page that exists; protecting non-existing pages is entirely meaningful.

That's still an open question. It would be nice, but it would be incompatible with Title, making the transition tricky. See discussion at T208776.

daniel updated the task description. (Show Details)Oct 11 2019, 9:06 AM
tosfos added a subscriber: tosfos.Mon, Oct 28, 7:56 PM
Vedmaka claimed this task.Fri, Nov 1, 1:37 PM

Change 549596 had a related patch set uploaded (by Vedmaka Wakalaka; owner: Vedmaka Wakalaka):
[mediawiki/core@master] Adds missing PHPUnit tests for the following Title methods:

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

Change 549596 merged by jenkins-bot:
[mediawiki/core@master] Adds missing PHPUnit tests for the following Title methods:

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

Change 549909 had a related patch set uploaded (by Vedmaka Wakalaka; owner: Vedmaka Wakalaka):
[mediawiki/core@master] Creates RestrictionStore service

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