Manual:Hooks/MultiContentSave
| MultiContentSave | |
|---|---|
| Available from version 1.35.0 (Gerrit change 467308) Before an article is saved. | |
| Define function: | public static function onMultiContentSave( MediaWiki\Revision\RenderedRevision $renderedRevision, MediaWiki\User\UserIdentity $user, MediaWiki\CommentStore\CommentStoreComment $summary, $flags, Status $hookStatus ) { ... }
|
| Attach hook: | In extension.json:
{
"Hooks": {
"MultiContentSave": "MediaWiki\\Extension\\MyExtension\\Hooks::onMultiContentSave"
}
}
|
| Called from: | File(s): Storage/PageUpdater.php |
| Interface: | MultiContentSaveHook.php |
For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:MultiContentSave extensions.
Details
edit$renderedRevision:MediaWiki\Revision\RenderedRevision(object) representing the planned revision. Provides access toParserOutputof all slots,MediaWiki\Revision\RevisionRecord, which containsTitleof the page that will be edited,MediaWiki\Revision\RevisionSlots- content of all slots, including inherited slots, where content has already been modified byPreSaveTransform.
- NOTE: because this revision is not yet saved, slots don't have content ID or address, and revision itself doesn't have an ID.
$user: theMediaWiki\User\UserIdentitysaving the article$summary:MediaWiki\CommentStore\CommentStoreCommentobject containing the edit comment.$flags: AllEDIT_…flags (includingEDIT_MINOR) as an integer number. SeeWikiPage::doEditContentdocumentation for flags' definition.$hookStatus: if the hook is aborted, error code can be placed into thisMediaWiki\Status\Status, e.g.$hookStatus->fatal( 'disallowed-by-some-extension' )- Return value: Return
falseto abort saving the page.
Examples
edit# Return false to cancel a save and use $status to provide an error message.
public function onMultiContentSave( $renderedRevision, $user, $summary, $flags, $hookStatus ) {
$hookStatus->fatal( new RawMessage( "Your Error Message Here!" ) );
return false;
}
See also
edit- PageContentSave: legacy hook, deprecated in favor of this one
- PageSaveComplete
- EditPage::attemptSave