Page MenuHomePhabricator

Implement a server-side mw.MessagePoster equivalent
Open, LowPublic

Description

We should have a server-side (PHP) equivalent of mw.MessagePoster. There are a lot of different places where things might want to leave a talk page note, like WikiLove, MassMessage, etc.

Note that both WikiLove and MassMessage are calling the API internally, I'm not sure if that's something we want to encourage in core.

This task does not include cross-wiki support.

To test, you can run the following in the shell:

$title = Title::newFromText( 'Talk:Page name' );
$handler = ContentHandler::getForTitle( $title );
$messagePoster = $handler->getMessagePoster();
$messagePoster->postTopic( $title, User::newFromName( 'User' ), 'Subject text', 'Some body' );

Once both the core and Flow changes are merged, it should work on either wikitext talk pages or Flow, depending on the title. The user in the final line is the editor/poster (they must have appropriate permissions, and this can also be tested).

For wikitext only (T73197), you can also test bot edits:

$messagePoster->postTopic( $title, User::newFromName( 'Bot' ), 'Bot test with flag', 'Some body', MediaWiki\MessagePoster\IMessagePoster::BOT_EDIT );

The user must have the bot flag (mwscript createAndPromote.php --wiki=wiki --bot Bot).

(This will show with a b in RecentChanges, and is filtered out out by default (but you can choose 'Show bots')).

Related Objects

Event Timeline

Legoktm raised the priority of this task from to Low.
Legoktm updated the task description. (Show Details)
Legoktm added a project: MediaWiki-General.
Legoktm added subscribers: Legoktm, Mattflaschen-WMF.

There's another case that needs this (currently broken), NewUserMessage.

Should I include cross-wiki support? It exists on the client side, but I don't know a use case on the server-side currently.

@Catrope and I agreed on IRC to leave it out for now.

Note that both WikiLove and MassMessage are calling the API internally, I'm not sure if that's something we want to encourage in core.

I think that is the best approach until EditPage is refactored, since we do need full permission checks, abuse filter, etc. etc. here. E.g. WikiLove is just using a DerivativeRequest right now (meaning the user's normal rights apply).

Change 307426 had a related patch set uploaded (by Mattflaschen):
WIP: Add server-side MessagePoster

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

Change 307464 had a related patch set uploaded (by Mattflaschen):
Add a server-side MessagePoster for Flow

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

Removing @Mattflaschen-WMF as task assignee to avoid cookie-licking.
(Matt, if you still like/plan to work on this, feel very welcome to re-claim via your personal Phab account - thanks!)

matmarex added a subscriber: matmarex.

This would allow for posting messages cross-wiki from wikis that do not have Flow installed to those that do. Example use case is VisualEditor's "Leave feedback" dialog.