Looking up redirects and maintaining the redirect table is currently done by WikiPage. This logic should be pulled out into a service object. There should be a separate interface that onyl covers the lookup aspect.
Interface draft:
interface RedirectLookup { getRedirectTarget( PageIdentity $page ): ?LinkTarget; } class RedirectStore implements RedirectLookup { getRedirectTarget( PageIdentity $page ): ?LinkTarget; updateRedirectTarget( PageIdentity $page, LinkTarget $target ); }
Original Description, for reference:
Looking up redirects is currently implemented in AbstractContent::getRedirectChain() and WikiPage::getRedirectTarget(). It should be handled by a storage layer service object instead.
Interface draft:
interface RedirectLookup { getRedirectChain( PageIdentity $page ): LinkTarget[]; getRedirectTarget( PageIdentity $page ): ?LinkTarget; getUltimateRedirectTarget( PageIdentity $page ): ?LinkTarget; }
The implementation should be based on the redirect table. The interface could be implemented separately, but putting the logic into PageStore may also be ok.
Note that Content should for now keep getRedirectTarget(), though it should not return a Title but a LinkTarget. That probably means deprecating the method and introducing a new one. That is however outside the scope of this task.