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, ServiceOptions $options)
 
 buildEditResult ()
 
 markAsRevert (int $revertMethod, int $newestRevertedRevId, int $revertAfterRevId=null)
 Marks this edit as a revert and applies relevant information. More...
 
 setIsNew (bool $isNew)
 Set whether the edit created a new page. More...
 
 setOriginalRevision ( $originalRevision)
 
 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...
 
 getOriginalRevision ()
 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...
 
 guessOriginalRevisionId ()
 In case we have not got the original revision ID, try to guess. 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
 
int null $newestRevertedRevId = null
 
int null $oldestRevertedRevId = null
 
ServiceOptions $options
 
RevisionRecord null $originalRevision = null
 
int bool $originalRevisionId = false
 
int null $revertAfterRevId = null
 
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,
ServiceOptions  $options 
)
Parameters
RevisionStore$revisionStore
string[]$softwareTagsArray of currently enabled software change tags. Can be obtained from ChangeTags::getSoftwareTags()
ServiceOptions$optionsOptions for this instance.

Definition at line 94 of file EditResultBuilder.php.

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

Member Function Documentation

◆ buildEditResult()

MediaWiki\Storage\EditResultBuilder::buildEditResult ( )
Returns
EditResult

Definition at line 109 of file EditResultBuilder.php.

◆ 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 218 of file EditResultBuilder.php.

References MediaWiki\MainConfigNames\ManualRevertSearchRadius, and MediaWiki\Storage\EditResult\REVERT_MANUAL.

◆ getOriginalRevision()

MediaWiki\Storage\EditResultBuilder::getOriginalRevision ( )
private

Returns the revision that is being repeated or restored.

Returns null if not set for this edit.

Returns
RevisionRecord|null

Definition at line 283 of file EditResultBuilder.php.

◆ 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 334 of file EditResultBuilder.php.

◆ guessOriginalRevisionId()

MediaWiki\Storage\EditResultBuilder::guessOriginalRevisionId ( )
private

In case we have not got the original revision ID, try to guess.

Definition at line 251 of file EditResultBuilder.php.

◆ 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 301 of file EditResultBuilder.php.

◆ 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 320 of file EditResultBuilder.php.

◆ markAsRevert()

MediaWiki\Storage\EditResultBuilder::markAsRevert ( int  $revertMethod,
int  $newestRevertedRevId,
int  $revertAfterRevId = null 
)

Marks this edit as a revert and applies relevant information.

Parameters
int$revertMethodThe method used to make the revert: REVERT_UNDO, REVERT_ROLLBACK or REVERT_MANUAL
int$newestRevertedRevIdthe revision ID of the latest reverted revision.
int | null$revertAfterRevIdthe revision ID after which revisions are being reverted. Defaults to the revision before the $newestRevertedRevId.

Definition at line 163 of file EditResultBuilder.php.

References MediaWiki\Storage\EditResult\REVERT_MANUAL, MediaWiki\Storage\EditResult\REVERT_ROLLBACK, and MediaWiki\Storage\EditResult\REVERT_UNDO.

◆ 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 150 of file EditResultBuilder.php.

◆ setOriginalRevision()

MediaWiki\Storage\EditResultBuilder::setOriginalRevision (   $originalRevision)
Parameters
RevisionRecord | int | bool | null$originalRevisionRevisionRecord or revision ID for the original revision. False or null to unset.

Definition at line 201 of file EditResultBuilder.php.

◆ 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 140 of file EditResultBuilder.php.

Member Data Documentation

◆ $isNew

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

Definition at line 59 of file EditResultBuilder.php.

◆ $newestRevertedRevId

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

Definition at line 71 of file EditResultBuilder.php.

◆ $oldestRevertedRevId

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

Definition at line 74 of file EditResultBuilder.php.

◆ $options

ServiceOptions MediaWiki\Storage\EditResultBuilder::$options
private

◆ $originalRevision

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

Definition at line 65 of file EditResultBuilder.php.

◆ $originalRevisionId

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

Definition at line 62 of file EditResultBuilder.php.

◆ $revertAfterRevId

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

Definition at line 77 of file EditResultBuilder.php.

◆ $revertMethod

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

Definition at line 68 of file EditResultBuilder.php.

◆ $revisionRecord

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

Definition at line 56 of file EditResultBuilder.php.

◆ $revisionStore

RevisionStore MediaWiki\Storage\EditResultBuilder::$revisionStore
private

◆ $softwareTags

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

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\Storage\EditResultBuilder::CONSTRUCTOR_OPTIONS
Initial value:
= [
]
const ManualRevertSearchRadius
Name constant for the ManualRevertSearchRadius setting, for use with Config::get()

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:

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: