Page MenuHomePhabricator

Start conversion of RevisionStore public interface to PageIdentity
Closed, ResolvedPublic

Description

Currently a number public RevisionStore methods accept Title or LinkTarget:

  • ::getRevisionByTitle
  • ::getRevisionByTimestamp
  • ::newRevisionFromArchiveRow
  • ::newRevisionFromArchiveRowAndSlots
  • ::newRevisionsFromBatch
  • ::newMutableRevisionFromArray - to be deprecated, see T272560
  • ::getKnownCurrentRevision
  • ::getFirstRevision

Some of these methods are inherited from various interfaces (RevisionFactory, RevisionLookup).
We need to accept PageIdentity in these methods as well, and soft-deprecate passing it Title object.

Additionally, some of these methods accept an array which can have a 'title' property - this should also be converted to accept PageIdentity as well as the Title under same key.

So, the LinkTarget parameter typehint should be removed for now (or changed to object) and the parameter declaration should be changed to

@param LinkTarget|PageIdentity $page the page this revision belongs to. Calling with LinkTarget is deprecated since 1.36

Internally, the methods should try using PageIdentity methods if possible with two exceptions:

  • getId of PageIdentity has much stricter guarantees then Title::getArticleId, and since the calling code still passes Title, we have to still cast to Title via Title::castFromPageIdentity and call getArticleId. See RevisionRecord::getArticleId for example.
  • If the called methods do not yet exist for PageIdentity, like Title::getLatestRevId, cast back to Title.

Tests for the converted methods should be adjusted to test both old interface (with Title) and new interface (with PageIdentityValue)

Note: EntitySchema extension extends RevisionLookup for testing purposes. This is not allowed by stable interface policy, so ArrayRevisionLookup should be changed into a mock before implementing this.

Event Timeline

Change 661461 had a related patch set uploaded (by Peter.ovchyn; owner: Peter.ovchyn):
[mediawiki/core@master] Update RevisionStore public interface to be using PageIdentity * RevisionStore::getRevisionByTitle

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

Change 662776 had a related patch set uploaded (by Peter.ovchyn; owner: Peter.ovchyn):
[mediawiki/extensions/EntitySchema@master] Avoid extension RevisionLookup in tests in favour of mocks

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

Change 662776 merged by jenkins-bot:
[mediawiki/extensions/EntitySchema@master] Avoid extension RevisionLookup in tests in favour of mocks

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

Change 661461 merged by jenkins-bot:
[mediawiki/core@master] Update RevisionStore public interface to be using PageIdentity

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