Page MenuHomePhabricator

Convert blocks to PageIdentity
Open, HighPublic

Description

Currently blocks and block restrictions are based on Title objects. They really don't need to - blocks only need pageId, dbkey and namespace, so the whole package can be moved to using PageIdentity.

Additionally, none of the block-related classes can be extended by extensions cause MW doesn't support custom block types, which means we can be quite cavalier with changing the types.

A few complications is that blocks do Title::newFrom* in a few places, however, they really don't need to:

  1. PageRestriction can be constructed via newFromRow, where row is a result of a left join on the page table on page_id, which means we can either instantiate a PageIdentityValue directly, right away, or the page table record with the given page ID doesn't exist, so retrying to instantiate a Title from the the same ID makes no sense.
  2. When constructing a log entry - that should remain, it's a boundary interface.

Proposal:

  1. Override constructor in PageRestriction constructor take ?PageIdentity. remove the $title filed, replace it with $page field.
  2. Change newFromRow to build up a PageIdentityValue instead of Title
  3. Deprecate PageRestriction::get/set Title, create PageRestriction::getPage():PageIdentity. No need to set one anymore.
  4. Adjust the rest of the code and mostly replace Title type hints with PageIdentity typegints - all should just fall into place.

Event Timeline

daniel raised the priority of this task from Medium to High.Feb 10 2021, 10:26 AM
daniel lowered the priority of this task from High to Medium.
daniel raised the priority of this task from Medium to High.

Change 673307 had a related patch set uploaded (by Peter.ovchyn; owner: Peter.ovchyn):
[mediawiki/core@master] Convert PageRestriction to PageIdentity instead of title

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

Change 673447 had a related patch set uploaded (by Vadim Kovalenko; owner: Peter.ovchyn):
[mediawiki/core@master] Convert PageRestriction to PageIdentity instead of title

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

Change 673447 abandoned by Vadim Kovalenko:
[mediawiki/core@master] Convert PageRestriction to PageIdentity instead of title

Reason:
This patch is irrelevant now.

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

Change #673307 abandoned by Bartosz Dziewoński:

[mediawiki/core@master] Convert PageRestriction to use PageIdentity instead of Title

Reason:

Patch author no longer works on MediaWiki. This change has enough merge conflicts and review comments that need to be addressed that it would probably be easier to rewrite it from scratch.

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