MediaWiki  master
MediaWiki\Storage\EditResultBuilder Class Reference

Builder class for the EditResult object. More...

Collaboration diagram for MediaWiki\Storage\EditResultBuilder:

Public Member Functions

 __construct (RevisionStore $revisionStore, array $softwareTags, ILoadBalancer $loadBalancer, ServiceOptions $options)
 EditResultBuilder constructor. More...
 
 buildEditResult ()
 Builds the EditResult object. More...
 
 markAsRevert (int $revertMethod, int $oldestRevertedRevId, int $newestRevertedRevId=0)
 Marks this edit as a revert and applies relevant information. More...
 
 setIsNew (bool $isNew)
 Set whether the edit created a new page. More...
 
 setOriginalRevisionId ( $originalRevId)
 Sets the ID of an earlier revision that is being repeated or restored. More...
 
 setRevisionRecord (RevisionRecord $revisionRecord)
 Set the revision associated with this edit. More...
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 

Private Member Functions

 detectManualRevert ()
 If this edit was not already marked as a revert using EditResultBuilder::markAsRevert(), tries to establish whether this was a manual revert, i.e. More...
 
 findIdenticalRevision (int $searchRadius)
 Tries to find an identical revision to $this->revisionRecord in $searchRadius most recent revisions of this page. More...
 
 getOriginalRevision (int $flags=RevisionStore::READ_NORMAL)
 Returns the revision that is being repeated or restored. More...
 
 getRevertTags ()
 Returns an array of revert-related tags that will be applied automatically to this edit. More...
 
 isExactRevert ()
 Whether the edit was an exact revert, i.e. More...
 
 isNullEdit ()
 An edit is a null edit if the original revision is equal to the parent revision. More...
 

Private Attributes

bool $isNew = false
 
ILoadBalancer $loadBalancer
 
int null $newestRevertedRevId = null
 
int null $oldestRevertedRevId = null
 
ServiceOptions $options
 
RevisionRecord null $originalRevision = null
 
bool int $originalRevisionId = false
 
int null $revertMethod = null
 
RevisionRecord null $revisionRecord = null
 
RevisionStore $revisionStore
 
string[] $softwareTags
 
const REVERT_METHOD_TO_CHANGE_TAG
 A mapping from EditResult's revert methods to relevant change tags. More...
 

Detailed Description

Builder class for the EditResult object.

Access: internal
Only for use by PageUpdater
Since
1.35

Definition at line 39 of file EditResultBuilder.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Storage\EditResultBuilder::__construct ( RevisionStore  $revisionStore,
array  $softwareTags,
ILoadBalancer  $loadBalancer,
ServiceOptions  $options 
)

EditResultBuilder constructor.

Parameters
RevisionStore$revisionStore
string[]$softwareTagsArray of currently enabled software change tags. Can be obtained from ChangeTags::getSoftwareTags()
ILoadBalancer$loadBalancer
ServiceOptions$optionsOptions for this instance.

Definition at line 97 of file EditResultBuilder.php.

References MediaWiki\Storage\EditResultBuilder\$loadBalancer, MediaWiki\Storage\EditResultBuilder\$options, MediaWiki\Storage\EditResultBuilder\$revisionStore, MediaWiki\Storage\EditResultBuilder\$softwareTags, and MediaWiki\Config\ServiceOptions\assertRequiredOptions().

Member Function Documentation

◆ buildEditResult()

◆ detectManualRevert()

MediaWiki\Storage\EditResultBuilder::detectManualRevert ( )
private

If this edit was not already marked as a revert using EditResultBuilder::markAsRevert(), tries to establish whether this was a manual revert, i.e.

someone restored the page to an exact previous state manually.

If successful, mutates the builder accordingly.

Definition at line 201 of file EditResultBuilder.php.

References MediaWiki\Storage\EditResultBuilder\findIdenticalRevision(), MediaWiki\Storage\EditResultBuilder\isNullEdit(), MediaWiki\Storage\EditResultBuilder\markAsRevert(), MediaWiki\Storage\EditResult\REVERT_MANUAL, and MediaWiki\Storage\EditResultBuilder\setOriginalRevisionId().

Referenced by MediaWiki\Storage\EditResultBuilder\buildEditResult().

◆ findIdenticalRevision()

MediaWiki\Storage\EditResultBuilder::findIdenticalRevision ( int  $searchRadius)
private

Tries to find an identical revision to $this->revisionRecord in $searchRadius most recent revisions of this page.

The comparison is based on SHA1s of these revisions.

Parameters
int$searchRadiusHow many recent revisions should be checked
Returns
RevisionStoreRecord|null

Definition at line 243 of file EditResultBuilder.php.

References $revQuery, and DB_MASTER.

Referenced by MediaWiki\Storage\EditResultBuilder\detectManualRevert().

◆ getOriginalRevision()

MediaWiki\Storage\EditResultBuilder::getOriginalRevision ( int  $flags = RevisionStore::READ_NORMAL)
private

Returns the revision that is being repeated or restored.

Returns null if not set for this edit.

Parameters
int$flagsAccess flags, e.g. RevisionStore::READ_LATEST
Returns
RevisionRecord|null

Definition at line 288 of file EditResultBuilder.php.

References MediaWiki\Storage\EditResultBuilder\$originalRevision.

Referenced by MediaWiki\Storage\EditResultBuilder\isExactRevert(), and MediaWiki\Storage\EditResultBuilder\isNullEdit().

◆ getRevertTags()

MediaWiki\Storage\EditResultBuilder::getRevertTags ( )
private

Returns an array of revert-related tags that will be applied automatically to this edit.

Returns
string[]

Definition at line 343 of file EditResultBuilder.php.

References MediaWiki\Storage\EditResultBuilder\$revertMethod.

Referenced by MediaWiki\Storage\EditResultBuilder\buildEditResult().

◆ isExactRevert()

MediaWiki\Storage\EditResultBuilder::isExactRevert ( )
private

Whether the edit was an exact revert, i.e.

the contents of the revert revision and restored revision match

Returns
bool

Definition at line 311 of file EditResultBuilder.php.

References MediaWiki\Storage\EditResultBuilder\getOriginalRevision().

Referenced by MediaWiki\Storage\EditResultBuilder\buildEditResult().

◆ isNullEdit()

MediaWiki\Storage\EditResultBuilder::isNullEdit ( )
private

An edit is a null edit if the original revision is equal to the parent revision.

Returns
bool

Definition at line 329 of file EditResultBuilder.php.

References MediaWiki\Storage\EditResultBuilder\getOriginalRevision().

Referenced by MediaWiki\Storage\EditResultBuilder\buildEditResult(), and MediaWiki\Storage\EditResultBuilder\detectManualRevert().

◆ markAsRevert()

MediaWiki\Storage\EditResultBuilder::markAsRevert ( int  $revertMethod,
int  $oldestRevertedRevId,
int  $newestRevertedRevId = 0 
)

Marks this edit as a revert and applies relevant information.

Will do nothing if $oldestRevertedRevId is 0.

Parameters
int$revertMethodThe method used to make the revert: REVERT_UNDO, REVERT_ROLLBACK or REVERT_MANUAL
int$oldestRevertedRevIdThe ID of the oldest revision that was reverted.
int$newestRevertedRevIdThe ID of the newest revision that was reverted. This parameter is optional, default value is $oldestRevertedRevId

Definition at line 168 of file EditResultBuilder.php.

References MediaWiki\Storage\EditResultBuilder\$newestRevertedRevId, MediaWiki\Storage\EditResultBuilder\$oldestRevertedRevId, and MediaWiki\Storage\EditResultBuilder\$revertMethod.

Referenced by MediaWiki\Storage\EditResultBuilder\detectManualRevert().

◆ setIsNew()

MediaWiki\Storage\EditResultBuilder::setIsNew ( bool  $isNew)

Set whether the edit created a new page.

Should only be called by PageUpdater when saving an edit.

Parameters
bool$isNew

Definition at line 154 of file EditResultBuilder.php.

References MediaWiki\Storage\EditResultBuilder\$isNew.

◆ setOriginalRevisionId()

MediaWiki\Storage\EditResultBuilder::setOriginalRevisionId (   $originalRevId)

Sets the ID of an earlier revision that is being repeated or restored.

Parameters
int | bool$originalRevId

Definition at line 190 of file EditResultBuilder.php.

Referenced by MediaWiki\Storage\EditResultBuilder\detectManualRevert().

◆ setRevisionRecord()

MediaWiki\Storage\EditResultBuilder::setRevisionRecord ( RevisionRecord  $revisionRecord)

Set the revision associated with this edit.

Should only be called by PageUpdater when saving an edit.

Parameters
RevisionRecord$revisionRecord

Definition at line 144 of file EditResultBuilder.php.

References MediaWiki\Storage\EditResultBuilder\$revisionRecord.

Member Data Documentation

◆ $isNew

bool MediaWiki\Storage\EditResultBuilder::$isNew = false
private

Definition at line 59 of file EditResultBuilder.php.

Referenced by MediaWiki\Storage\EditResultBuilder\setIsNew().

◆ $loadBalancer

ILoadBalancer MediaWiki\Storage\EditResultBuilder::$loadBalancer
private

◆ $newestRevertedRevId

int null MediaWiki\Storage\EditResultBuilder::$newestRevertedRevId = null
private

◆ $oldestRevertedRevId

int null MediaWiki\Storage\EditResultBuilder::$oldestRevertedRevId = null
private

◆ $options

ServiceOptions MediaWiki\Storage\EditResultBuilder::$options
private

◆ $originalRevision

RevisionRecord null MediaWiki\Storage\EditResultBuilder::$originalRevision = null
private

◆ $originalRevisionId

bool int MediaWiki\Storage\EditResultBuilder::$originalRevisionId = false
private

Definition at line 62 of file EditResultBuilder.php.

◆ $revertMethod

int null MediaWiki\Storage\EditResultBuilder::$revertMethod = null
private

◆ $revisionRecord

RevisionRecord null MediaWiki\Storage\EditResultBuilder::$revisionRecord = null
private

◆ $revisionStore

RevisionStore MediaWiki\Storage\EditResultBuilder::$revisionStore
private

◆ $softwareTags

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

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\Storage\EditResultBuilder::CONSTRUCTOR_OPTIONS
Initial value:
= [
'ManualRevertSearchRadius',
]

Definition at line 41 of file EditResultBuilder.php.

Referenced by MediaWiki\Storage\PageUpdater\__construct().

◆ REVERT_METHOD_TO_CHANGE_TAG

const MediaWiki\Storage\EditResultBuilder::REVERT_METHOD_TO_CHANGE_TAG
private
Initial value:
= [
EditResult::REVERT_ROLLBACK => 'mw-rollback',
EditResult::REVERT_MANUAL => 'mw-manual-revert'
]

A mapping from EditResult's revert methods to relevant change tags.

For use by getRevertTags()

Definition at line 49 of file EditResultBuilder.php.


The documentation for this class was generated from the following file:
MediaWiki\Storage\EditResult\REVERT_ROLLBACK
const REVERT_ROLLBACK
Definition: EditResult.php:42
MediaWiki\Storage\EditResult\REVERT_UNDO
const REVERT_UNDO
Definition: EditResult.php:41
MediaWiki\Storage\EditResult\REVERT_MANUAL
const REVERT_MANUAL
Definition: EditResult.php:43