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')).