Manual:Hooks/PageContentSave

From MediaWiki.org
Jump to: navigation, search
PageContentSave
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:
$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.

Details[edit]

  • $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)

Examples[edit]

# Uses $status to cancel a save
$wgHooks['PageContentSave'][] = function($wikiPage, $user, $content, $summary, $isMinor, $isWatch, $section, $flags, $status){
        if(true){
                $status->fatal(new RawMessage("Your Error Message Here!"));
        }
}

See also[edit]