Page MenuHomePhabricator

Add new ContentModelChangeFactory interface, implement with PageCommandFactory
Closed, ResolvedPublic

Description

In T107174: Add an API action to just change content model I added a ContentModelChange class to be used by both Special:ChangeContentModel and the new api module. It currently has a PermissionManager injected, but calls on MediaWikiServices for a ContentHandlerFactory and RevisionLookup, and after the migration of hooks will use the HookContainer service.

I propose that the PageCommandFactory implement a new interface, ContentModelChangeFactory, to fully inject these dependencies.
Since the ContentModelChange class was only added in 1.35, breaking changes can be made

interface
interface ContentModelChangeFactory {

    /**
     * @param User $user
     * @param WikiPage $wikipage
     * @param string $newModel
     * @return ContentModelChange
     */
    public function newContentModelChange( User $user, WikiPage $wikipage, string $newModel ) : ContentModelChange;
}

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
DannyS712 moved this task from Unsorted to Next on the User-DannyS712 board.
DannyS712 added subscribers: Pchelolo, daniel.

This is a follow up to T249446: Add a MergeHistoryFactory and convert MergeHistory to DI which added this common factory

Will wait until after the migration of hook callers before proceeding, to avoid conflicts

Sounds good. Is it possible to use UserIdentity instead of the User?

Sounds good. Is it possible to use UserIdentity instead of the User?

PermissionManager::getPermissionErrors requires a full user object, so no

Sounds good. Is it possible to use UserIdentity instead of the User?

PermissionManager::getPermissionErrors requires a full user object, so no

What's really needed here is an Authority object, see T231930.
It's annoying to create new interfaces that rely on old types. That means we will soon have to replace them again. But I don't see a good way around this at the moment.

Change 600402 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/core@master] Add ContentModelChangeFactory, implemented by PageCommandFactory

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

Change 600402 merged by jenkins-bot:
[mediawiki/core@master] Add ContentModelChangeFactory, implemented by PageCommandFactory

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