Manual:Hooks/MultiContentSave

MultiContentSave
Available from version 1.35.0 (Gerrit change 467308)
Before an article is saved.
Define function:
public static function onMultiContentSave( RenderedRevision $renderedRevision, User $user, CommentStoreComment $summary, $flags, Status $hookStatus ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"MultiContentSave": "MyExtensionHooks::onMultiContentSave"
	}
}
Called from:File(s): Storage/PageUpdater.php
Interface:MultiContentSaveHook.php

For more information about attaching hooks, see $1.
For examples of extensions using this hook, see Category:MultiContentSave extensions.

DetailsEdit

  • $renderedRevision: RenderedRevision (object) representing the planned revision. Provides access to
    (1) ParserOutput of all slots,
    (2) RevisionRecord, which contains
    (2a) Title of the page that will be edited,
    (2b) RevisionSlots - content of all slots, including inherited slots, where content has already been modified by PreSaveTransform.
    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: the User (object) saving the article
  • $summary: CommentStoreComment object containing the edit comment.
  • $flags: All EDIT_… flags (including EDIT_MINOR) as an integer number. See WikiPage::doEditContent documentation for flags' definition.
  • $hookStatus: if the hook is aborted, error code can be placed into this Status, e.g. $hookStatus->fatal( 'disallowed-by-some-extension' )
  • Return value: Return false to abort saving the page.

ExamplesEdit

# Return false to cancel a save and use $status to provide an error message.
$wgHooks['MultiContentSave'][] = function ( $renderedRevision, $user, $summary, $flags, $hookStatus ) {
	$hookStatus->fatal( new RawMessage( "Your Error Message Here!" ) );
	return false;
}

See alsoEdit