This RFC proposes to introduce:
- PageRecord: a lightweight data object for representing wiki pages (that is, entries in the page table).
- PageLookup: a narrow service interface for looking up such page entries by id or title.
Proto-Code of for PageRecord and PageLookup can be found towards the end of the proposal.
Rationale
Reduce usage of the Title object. Title is a heavy weight smart record with many dependencies, and tightly bound to the database layer. Replacing it with something more lightweight would improve modularity and testability.
TitleValue was introduced as a replacement of Title in cases where only the namespace and title text are known or needed. Such cases however are rather rare, in most cases more information is desired: we need a lightweight representation of existing wiki pages, not just of titles of pages that may exist.
PageLookup would also complement the infrastructure proposed at T107595: [RFC] Multi-Content Revisions.
Proto-Code
class PageRecord { public function getTitle(); // @return TitleValue public function getId(); // @return int public function isRedirect(); // @return bool public function getLatestRevisionId(); // @return int public function getTouchedDate(); // @return string public function getLanguageCode(); // @return string public function getContentModel(); // @return string } class PageLookup { public function findPageById( $id ); public function findPageByTitle( $ns, $title ); }
Other services that list pages by some property can be added as need be. A generic mechanism for listing PageRecords could be implemented to replace QueryPage (or QueryPage could be re-implemented to use it).
Migration
Migration from Title to PageRecord would be done incrementally over time. For compatibility, Title would get two new methods:
class Title { ... public static function newFromPageRecord( PageRecord $page ); // @return Title public function getPageRecord(); // @return PageRecord ... }