Manual:Hooks/ArticleSaveComplete

From Linux Web Expert

Revision as of 19:34, 9 July 2023 by imported>RobinHood70 (→‎Details: Same format as others)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

ArticleSaveComplete
<translate> Available from <tvar name=1><translate> version <tvar </tvar></translate>
<translate> Removed in <tvar name=1><translate> version <tvar </tvar></translate>
Occurs after the save article request has been processed.
<translate> Define function:</translate>
public static function onArticleSaveComplete( &$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId ) { ... }
<translate> Attach hook:</translate> <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
	"Hooks": {
		"ArticleSaveComplete": "MediaWiki\\Extension\\MyExtension\\Hooks::onArticleSaveComplete"
	}
}
<translate> Called from:</translate> <translate> File(s):</translate> WikiPage.php
<translate> Interface:</translate> ArticleSaveCompleteHook.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:ArticleSaveComplete extensions</tvar>.</translate>


Details

  • $article: the Article (object) saved
  • $user: the User (object) who saved the article
  • $text: the new article text
  • $summary: the article summary (comment)
  • $minoredit: minor flag
  • $watchthis: not used as of 1.8
  • $section: not used as of 1.8
  • $flags: bitfield, see includes/Article.php for details
  • $revision: the new Revision object that was just saved or NULL if the user clicked save without changing any page text 1.11+
  • $status: the Status object that will be returned by Article::doEdit() 1.14+
  • $baseRevId: revision ID on which this edit is based 1.15+

The function should return true to continue hook processing or false to abort. This hook will be triggered both by edits made through the edit page, and by edits made through the API.

Notes

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

  • Version 1.4.x - 1.5.x: included in EditPage.php and Image.php.
  • Version 1.6.x - 1.10.x: included in Article::updateArticle() and Article::insertArticle().
  • Version 1.11+: included in Article::doEdit().
  • Version 1.18+: moved to WikiPage.php

insertNewArticle() and updateArticle() will watch/unwatch pages after doEdit() (and hence ArticleSaveComplete) are run.

Example handler

/**
 * Occurs after the save article request has been processed.
 * @see https://www.mediawiki.org/wiki/Manual:Hooks/ArticleSaveComplete
 *
 * @param WikiPage $article
 * @param User $user
 * @param string $text
 * @param string $summary
 * @param boolean $minoredit
 * @param boolean $watchthis
 * @param $sectionanchor deprecated
 * @param integer $flags
 * @param Revision $revision
 * @param Status $status
 * @param integer $baseRevId
 *
 * @return boolean
 */
public static function onArticleSaveComplete( WikiPage &$article, User &$user, $text, $summary,
		$minoredit, $watchthis, $sectionanchor, &$flags, Revision $revision, Status &$status, $baseRevId ) {

}

See also