Page MenuHomePhabricator

Make PageArchive a proper service
Open, Needs TriagePublic

Description

The class is not newable, but callers have no choice but to instantiate it, which several extensions (+ core) are doing. It should be a proper service instead.

The general plan for this is to have:

  • A command object (UndeletePage) for actual deletion, moving undeleteAsUser() and dependencies there, similar to DeletePage
  • A lookup service (ArchivedRevisionLookup) with the remaining stuff, similar to RevisionLookup and perhaps sharing a common interface with it

Event Timeline

I don't think something like new PageArchive( $title, /* ... */ ) can simply become a service (i.e. it's instantiated with a title object).

See also this todo remark in its constructor:

// TODO: Refactor: delete()/undeleteAsUser() should live in a PageStore service;
//       Methods in PageArchive and RevisionStore that deal with archive revisions
//       should move into an ArchiveStore service (but could still be implemented
//       together with RevisionStore).

Anyway, yes, it's a mess.

I don't think something like new PageArchive( $title, /* ... */ ) can simply become a service (i.e. it's instantiated with a title object).

Good point. If the title is really necessary in the constructor, there should be a PageArchiveFactory.

See also this todo remark in its constructor:

// TODO: Refactor: delete()/undeleteAsUser() should live in a PageStore service;
//       Methods in PageArchive and RevisionStore that deal with archive revisions
//       should move into an ArchiveStore service (but could still be implemented
//       together with RevisionStore).

That's also a good point, I'll get back on this once T288242 is done to see what we can do.