Jump to content

Manual:Hooks/BeforeRevertedTagUpdate

From mediawiki.org
BeforeRevertedTagUpdate
Available from version 1.36.0 (Gerrit change 609773)
This hook is called before scheduling a RevertedTagUpdateJob.
Define function:
public static function onBeforeRevertedTagUpdate( $wikiPage, $user, $summary,$flags, $revisionRecord, $editResult, &$approved ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"BeforeRevertedTagUpdate": "MediaWiki\\Extension\\MyExtension\\Hooks::onBeforeRevertedTagUpdate"
	}
}
Called from: File(s): Storage/PageUpdater.php
Function(s): getAtomicSectionUpdate
Interface: BeforeRevertedTagUpdateHook.php

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


Various content management extensions that involve some kind of approval mechanism for edits can use this to indicate that the MediaWiki\Storage\RevertedTagUpdate should not be performed right after the edit is made, but rather it should wait for the edit to be approved. To delay the execution of the update simply implement this hook and set the $approved parameter to false when the user does not have an "autoreview" user right or similar.

The update can be later rescheduled using MediaWiki\Storage\RevertedTagUpdateManager. In your code that marks an edit as "approved" use:

$revertedTagUpdateManager = MediaWikiServices::getInstance()->getRevertedTagUpdateManager();
$revertedTagUpdateManager->approveRevertedTagForRevision( $acceptedRevisionId );

Parameters

[edit]
  • $wikiPage: WikiPage modified
  • $user: The user performing the modification, instance of MediaWiki\User\UserIdentity
  • $summary: Edit summary/comment, instance of CommentStoreComment
  • $flags: An int, Flags passed to WikiPage::doEditContent()
  • $revisionRecord: New MediaWiki\Revision\RevisionRecord of the article
  • $editResult: A MediaWiki\Storage\EditResult object storing information about the effects of this edit, including which edits were reverted and which edit is this based on (for reverts and null edits).
  • &$approved: A bool, representing whether the edit is considered approved. Setting it to false will abort the update, while setting it to true will cause the update to be executed normally. If patrolling is enabled, the passed value will indicate whether the edit is autopatrolled or not. In case patrolling is disabled on the wiki, the passed value will always be true, unless modified by other extensions.