Manual:Hooks/ArticleSave/1.5

From MediaWiki.org
Jump to navigation Jump to search
ArticleSave
Available from version 1.4.0
Occurs whenever the software receives a request to save an article
Define function:
public static function onArticleSave( &$article, &$user, &$text, &$summary, &$minoredit, &$watchthis, &$sectionanchor ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"ArticleSave": "MyExtensionHooks::onArticleSave"
	}
}

For MediaWiki ≤1.25:

$wgHooks['ArticleSave'][] = 'MyExtensionHooks::onArticleSave';
Called from:File(s): Article.php

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

Details[edit]

  • $article: the article (object) being saved
  • $user: the user (object) saving the article
  • $text: the new article text
  • $summary: the article summary (comment)
  • $isminor: minor flag
  • $iswatch: watch flag
  • $section: section #

Notes[edit]

This did not apply to newly uploaded images until v1.4.5.

In previous versions, this hook was included in EditPage.php: EditPage.attemptSave() and Image.php: RecordUpload()

See also[edit]