Jump to navigation Jump to search
Available from version 1.21.0
Before an article is saved.
Define function:
public static function onPageContentSave( &$wikiPage, &$user, &$content, &$summary, 
$isMinor, $isWatch, $section, &$flags, &$status ) { ... }
Attach hook:

In extension.json:

	"Hooks": {
		"PageContentSave": "MyExtensionHooks::onPageContentSave"

For MediaWiki ≤1.25:

$wgHooks['PageContentSave'][] = 'MyExtensionHooks::onPageContentSave';
Called from:File(s): WikiPage.php

For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:PageContentSave extensions.


  • $wikiPage: the WikiPage (object) being saved
  • $user: the User (object) saving the article
  • $content: the new article content, as a Content object
  • $summary: the article summary (comment)
  • $isMinor: minor flag
  • $isWatch: watch flag (not used, aka always null)
  • $section: section number (not used, aka always null)
  • $flags: see WikiPage::doEditContent documentation for flags' definition
  • $status: Status (object)
  • Return value: Return false to abort saving the page.


# Return false to cancel a save and use $status to provide an error message.
$wgHooks['PageContentSave'][] = function( $wikiPage, $user, $content, $summary, $isMinor, $isWatch, $section, $flags, $status) {
	if ( true ) {
		$status->fatal( new RawMessage( "Your Error Message Here!" ) );
	return false;

See also[edit]