Manual:Hooks/MultiContentSave
From Linux Web Expert
MultiContentSave | |
---|---|
<translate> Available from <tvar name=1><translate> version <tvar (Gerrit change 467308)</tvar></translate> Before an article is saved. | |
<translate> Define function:</translate> | public static function onMultiContentSave( MediaWiki\Revision\RenderedRevision $renderedRevision, MediaWiki\User\UserIdentity $user, CommentStoreComment $summary, $flags, Status $hookStatus ) { ... }
|
<translate> Attach hook:</translate> | <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
"Hooks": {
"MultiContentSave": "MediaWiki\\Extension\\MyExtension\\Hooks::onMultiContentSave"
}
}
|
<translate> Called from:</translate> | <translate> File(s):</translate> Storage/PageUpdater.php |
<translate> Interface:</translate> | MultiContentSaveHook.php |
<translate> For more information about attaching hooks, see <tvar name=1>Manual:Hooks </tvar>.</translate>
<translate> For examples of extensions using this hook, see <tvar name=cat>Category:MultiContentSave extensions</tvar>.</translate>
Details
$renderedRevision
:MediaWiki\Revision\RenderedRevision
(object) representing the planned revision. Provides access toParserOutput
of all slots,MediaWiki\Revision\RevisionRecord
, which containsTitle
of 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\UserIdentity
saving the article$summary
:CommentStoreComment
object containing the edit comment.$flags
: AllEDIT_…
flags (includingEDIT_MINOR
) as an integer number. SeeWikiPage::doEditContent
documentation for flags' definition.$hookStatus
: if the hook is aborted, error code can be placed into thisStatus
, e.g.$hookStatus->fatal( 'disallowed-by-some-extension' )
- Return value: Return
false
to abort saving the page.
Examples
# 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 also
- PageContentSave: legacy hook, deprecated in favor of this one
- PageSaveComplete
- EditPage::attemptSave