MediaWiki  master
MediaWiki\Storage\RevertedTagUpdate Class Reference

Adds the mw-reverted tag to reverted edits after a revert is made. More...

Inheritance diagram for MediaWiki\Storage\RevertedTagUpdate:
Collaboration diagram for MediaWiki\Storage\RevertedTagUpdate:

Public Member Functions

 __construct (RevisionStore $revisionStore, LoggerInterface $logger, array $softwareTags, ILoadBalancer $loadBalancer, ServiceOptions $serviceOptions, int $revertId, EditResult $editResult)
 
 doUpdate ()
 Marks reverted edits with mw-reverted tag. More...
 

Public Attributes

const CONSTRUCTOR_OPTIONS = [ 'RevertedTagMaxDepth' ]
 

Protected Member Functions

 getChangeTags (int $revisionId)
 Protected function calling static ChangeTags class to allow for unit testing of this deferrable update. More...
 
 markAsReverted (int $revisionId, array $extraParams)
 Protected function calling static ChangeTags class to allow for unit testing of this deferrable update. More...
 

Private Member Functions

 getNewestRevertedRevision ()
 Returns the newest revision record that was reverted. More...
 
 getOldestRevertedRevision ()
 Returns the oldest revision record that was reverted. More...
 
 getRevertRevision ()
 Returns the revision that performed the revert. More...
 
 getTagExtraParams ()
 Returns additional data to be saved in ct_params field of table 'change_tag'. More...
 
 handleSingleRevertedEdit ()
 Handles the case where only one edit was reverted. More...
 
 shouldExecute ()
 Performs checks to determine whether the update should execute. More...
 

Private Attributes

EditResult $editResult
 
ILoadBalancer $loadBalancer
 
LoggerInterface $logger
 
RevisionRecord null $newestRevertedRevision
 
RevisionRecord null $oldestRevertedRevision
 
ServiceOptions $options
 
int $revertId
 
RevisionRecord null $revertRevision
 
RevisionStore $revisionStore
 
string[] $softwareTags
 

Detailed Description

Adds the mw-reverted tag to reverted edits after a revert is made.

This class is used by RevertedTagUpdateJob to perform the actual update.

Since
1.36

Definition at line 41 of file RevertedTagUpdate.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Storage\RevertedTagUpdate::__construct ( RevisionStore  $revisionStore,
LoggerInterface  $logger,
array  $softwareTags,
ILoadBalancer  $loadBalancer,
ServiceOptions  $serviceOptions,
int  $revertId,
EditResult  $editResult 
)
Parameters
RevisionStore$revisionStore
LoggerInterface$logger
string[]$softwareTagsArray of currently enabled software change tags. Can be obtained from ChangeTags::getSoftwareTags()
ILoadBalancer$loadBalancer
ServiceOptions$serviceOptions
int$revertIdID of the revert
EditResult$editResultEditResult object of this revert

Definition at line 88 of file RevertedTagUpdate.php.

References MediaWiki\Storage\RevertedTagUpdate\$editResult, MediaWiki\Storage\RevertedTagUpdate\$loadBalancer, MediaWiki\Storage\RevertedTagUpdate\$logger, MediaWiki\Storage\RevertedTagUpdate\$revertId, MediaWiki\Storage\RevertedTagUpdate\$revisionStore, MediaWiki\Storage\RevertedTagUpdate\$softwareTags, and MediaWiki\Config\ServiceOptions\assertRequiredOptions().

Member Function Documentation

◆ doUpdate()

◆ getChangeTags()

MediaWiki\Storage\RevertedTagUpdate::getChangeTags ( int  $revisionId)
protected

Protected function calling static ChangeTags class to allow for unit testing of this deferrable update.

This class is not stable for extending, this is just to make the class testable.

ChangeTags should be passed by dependency injection when that becomes possible. See: T245964

Parameters
int$revisionId
Returns
string[]

Definition at line 322 of file RevertedTagUpdate.php.

References DB_REPLICA, and ChangeTags\getTags().

Referenced by MediaWiki\Storage\RevertedTagUpdate\shouldExecute().

◆ getNewestRevertedRevision()

MediaWiki\Storage\RevertedTagUpdate::getNewestRevertedRevision ( )
private

Returns the newest revision record that was reverted.

Returns
RevisionRecord|null

Definition at line 363 of file RevertedTagUpdate.php.

References MediaWiki\Storage\RevertedTagUpdate\$newestRevertedRevision.

Referenced by MediaWiki\Storage\RevertedTagUpdate\doUpdate(), and MediaWiki\Storage\RevertedTagUpdate\shouldExecute().

◆ getOldestRevertedRevision()

MediaWiki\Storage\RevertedTagUpdate::getOldestRevertedRevision ( )
private

◆ getRevertRevision()

MediaWiki\Storage\RevertedTagUpdate::getRevertRevision ( )
private

Returns the revision that performed the revert.

Returns
RevisionRecord|null

Definition at line 349 of file RevertedTagUpdate.php.

References MediaWiki\Storage\RevertedTagUpdate\$revertRevision.

Referenced by MediaWiki\Storage\RevertedTagUpdate\shouldExecute().

◆ getTagExtraParams()

MediaWiki\Storage\RevertedTagUpdate::getTagExtraParams ( )
private

Returns additional data to be saved in ct_params field of table 'change_tag'.

Effectively a superset of what EditResult::jsonSerialize() returns.

Returns
array

Definition at line 337 of file RevertedTagUpdate.php.

Referenced by MediaWiki\Storage\RevertedTagUpdate\doUpdate(), and MediaWiki\Storage\RevertedTagUpdate\shouldExecute().

◆ handleSingleRevertedEdit()

MediaWiki\Storage\RevertedTagUpdate::handleSingleRevertedEdit ( )
private

Handles the case where only one edit was reverted.

Returns true if the update was handled by this method, false otherwise.

This is a much simpler case requiring less DB queries than when dealing with multiple reverted edits.

Returns
bool

Definition at line 254 of file RevertedTagUpdate.php.

References MediaWiki\Revision\RevisionRecord\DELETED_TEXT, MediaWiki\Storage\RevertedTagUpdate\getOldestRevertedRevision(), and MediaWiki\Storage\RevertedTagUpdate\markAsReverted().

Referenced by MediaWiki\Storage\RevertedTagUpdate\doUpdate().

◆ markAsReverted()

MediaWiki\Storage\RevertedTagUpdate::markAsReverted ( int  $revisionId,
array  $extraParams 
)
protected

Protected function calling static ChangeTags class to allow for unit testing of this deferrable update.

This class is not stable for extending, this is just to make the class testable.

ChangeTags should be passed by dependency injection when that becomes possible. See: T245964

Parameters
int$revisionIdID of the revision to mark as reverted
array$extraParamsParams to put in the ct_params field of table 'change_tag'

Definition at line 299 of file RevertedTagUpdate.php.

References ChangeTags\addTags(), FormatJson\encode(), and ChangeTags\TAG_REVERTED.

Referenced by MediaWiki\Storage\RevertedTagUpdate\doUpdate(), and MediaWiki\Storage\RevertedTagUpdate\handleSingleRevertedEdit().

◆ shouldExecute()

Member Data Documentation

◆ $editResult

EditResult MediaWiki\Storage\RevertedTagUpdate::$editResult
private

◆ $loadBalancer

ILoadBalancer MediaWiki\Storage\RevertedTagUpdate::$loadBalancer
private

◆ $logger

LoggerInterface MediaWiki\Storage\RevertedTagUpdate::$logger
private

◆ $newestRevertedRevision

RevisionRecord null MediaWiki\Storage\RevertedTagUpdate::$newestRevertedRevision
private

◆ $oldestRevertedRevision

RevisionRecord null MediaWiki\Storage\RevertedTagUpdate::$oldestRevertedRevision
private

◆ $options

ServiceOptions MediaWiki\Storage\RevertedTagUpdate::$options
private

Definition at line 61 of file RevertedTagUpdate.php.

◆ $revertId

int MediaWiki\Storage\RevertedTagUpdate::$revertId
private

◆ $revertRevision

RevisionRecord null MediaWiki\Storage\RevertedTagUpdate::$revertRevision
private

◆ $revisionStore

RevisionStore MediaWiki\Storage\RevertedTagUpdate::$revisionStore
private

◆ $softwareTags

string [] MediaWiki\Storage\RevertedTagUpdate::$softwareTags
private

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\Storage\RevertedTagUpdate::CONSTRUCTOR_OPTIONS = [ 'RevertedTagMaxDepth' ]
Access: internal

Definition at line 46 of file RevertedTagUpdate.php.


The documentation for this class was generated from the following file: