MediaWiki  master
MediaWiki\Storage\EditResult Class Reference

Object for storing information about the effects of an edit. More...

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

Public Member Functions

 __construct (bool $isNew, $originalRevisionId, ?int $revertMethod, ?int $oldestReverted, ?int $newestReverted, bool $isExactRevert, bool $isNullEdit, array $revertTags)
 EditResult constructor. More...
 
 getNewestRevertedRevisionId ()
 Returns the ID of the most recent revision that was reverted by this edit. More...
 
 getOldestRevertedRevisionId ()
 Returns the ID of the oldest revision that was reverted by this edit. More...
 
 getOriginalRevisionId ()
 Returns the ID of an earlier revision that is being repeated or restored. More...
 
 getRevertMethod ()
 Returns the revert method that was used to perform the edit, if any changes were reverted. More...
 
 getRevertTags ()
 Returns an array of revert-related tags that were applied automatically to this edit. More...
 
 getUndidRevId ()
 If the edit was an undo, returns the oldest revision that was undone. More...
 
 isExactRevert ()
 Whether the edit was an exact revert, i.e. More...
 
 isNew ()
 Whether the edit created a new page. More...
 
 isNullEdit ()
 An edit is a null edit if the original revision is equal to the parent revision, i.e. More...
 
 isRevert ()
 Whether the edit was a revert, not necessarily exact. More...
 
 jsonSerialize ()
 Returns an array representing the EditResult object. More...
 

Static Public Member Functions

static newFromArray (array $a)
 Recreate the EditResult object from its array representation. More...
 

Public Attributes

const REVERT_MANUAL = 3
 
const REVERT_ROLLBACK = 2
 
const REVERT_UNDO = 1
 

Private Attributes

bool $isExactRevert
 
bool $isNew
 
bool $isNullEdit
 
int null $newestRevertedRevId
 
int null $oldestRevertedRevId
 
bool int $originalRevisionId
 
int null $revertMethod
 
string[] $revertTags
 
const SERIALIZATION_FORMAT_VERSION = '1'
 

Detailed Description

Object for storing information about the effects of an edit.

This object should be constructed by an EditResultBuilder with relevant information filled in during the process of saving the revision by the PageUpdater. You can use it to extract information about whether the edit was a revert and which edits were reverted.

Since
1.35

Definition at line 38 of file EditResult.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Storage\EditResult::__construct ( bool  $isNew,
  $originalRevisionId,
?int  $revertMethod,
?int  $oldestReverted,
?int  $newestReverted,
bool  $isExactRevert,
bool  $isNullEdit,
array  $revertTags 
)

EditResult constructor.

Parameters
bool$isNew
bool | int$originalRevisionId
int | null$revertMethod
int | null$oldestReverted
int | null$newestReverted
bool$isExactRevert
bool$isNullEdit
string[]$revertTags

Definition at line 85 of file EditResult.php.

References MediaWiki\Storage\EditResult\$isExactRevert, MediaWiki\Storage\EditResult\$isNew, MediaWiki\Storage\EditResult\$isNullEdit, MediaWiki\Storage\EditResult\$originalRevisionId, MediaWiki\Storage\EditResult\$revertMethod, MediaWiki\Storage\EditResult\$revertTags, MediaWiki\Storage\EditResult\isExactRevert(), MediaWiki\Storage\EditResult\isNew(), and MediaWiki\Storage\EditResult\isNullEdit().

Member Function Documentation

◆ getNewestRevertedRevisionId()

MediaWiki\Storage\EditResult::getNewestRevertedRevisionId ( )

Returns the ID of the most recent revision that was reverted by this edit.

The same as getOldestRevertedRevisionId if only a single revision was reverted. Returns null if the edit was not a revert.

See also
EditResult::isRevert() for information on how a revert is defined
Returns
int|null

Definition at line 147 of file EditResult.php.

References MediaWiki\Storage\EditResult\$newestRevertedRevId.

◆ getOldestRevertedRevisionId()

MediaWiki\Storage\EditResult::getOldestRevertedRevisionId ( )

Returns the ID of the oldest revision that was reverted by this edit.

The same as getOldestRevertedRevisionId if only a single revision was reverted. Returns null if the edit was not a revert.

See also
EditResult::isRevert() for information on how a revert is defined
Returns
int|null

Definition at line 160 of file EditResult.php.

References MediaWiki\Storage\EditResult\$oldestRevertedRevId.

Referenced by MediaWiki\Storage\EditResult\getUndidRevId(), and MediaWiki\Storage\EditResult\isRevert().

◆ getOriginalRevisionId()

MediaWiki\Storage\EditResult::getOriginalRevisionId ( )

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

The original revision's content should match the new revision exactly.

Returns
bool|int The original revision id, or false if no earlier revision is known to be repeated or restored. The old PageUpdater::getOriginalRevisionId() returned false in such cases. This value would be then passed on to extensions through hooks, so it may be wise to keep compatibility with the old behavior.

Definition at line 188 of file EditResult.php.

References MediaWiki\Storage\EditResult\$originalRevisionId.

Referenced by MediaWiki\Storage\PageUpdater\doModify(), and MediaWiki\Storage\PageUpdater\getAtomicSectionUpdate().

◆ getRevertMethod()

MediaWiki\Storage\EditResult::getRevertMethod ( )

Returns the revert method that was used to perform the edit, if any changes were reverted.

Returns null if the edit was not a revert.

Possible values: REVERT_UNDO, REVERT_ROLLBACK, REVERT_MANUAL

See also
EditResult::isRevert()
Returns
int|null

Definition at line 231 of file EditResult.php.

References MediaWiki\Storage\EditResult\$revertMethod.

Referenced by MediaWiki\Storage\EditResult\getUndidRevId().

◆ getRevertTags()

MediaWiki\Storage\EditResult::getRevertTags ( )

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

Returns
string[]

Definition at line 260 of file EditResult.php.

References MediaWiki\Storage\EditResult\$revertTags.

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

◆ getUndidRevId()

MediaWiki\Storage\EditResult::getUndidRevId ( )

If the edit was an undo, returns the oldest revision that was undone.

Method kept for compatibility reasons.

Returns
int

Definition at line 170 of file EditResult.php.

References MediaWiki\Storage\EditResult\getOldestRevertedRevisionId(), and MediaWiki\Storage\EditResult\getRevertMethod().

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

◆ isExactRevert()

MediaWiki\Storage\EditResult::isExactRevert ( )

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

the contents of the revert revision and restored revision match

Returns
bool

Definition at line 241 of file EditResult.php.

References MediaWiki\Storage\EditResult\$isExactRevert.

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

◆ isNew()

MediaWiki\Storage\EditResult::isNew ( )

Whether the edit created a new page.

Returns
bool

Definition at line 197 of file EditResult.php.

References MediaWiki\Storage\EditResult\$isNew.

Referenced by MediaWiki\Storage\EditResult\__construct(), and MediaWiki\Storage\EditResult\isRevert().

◆ isNullEdit()

MediaWiki\Storage\EditResult::isNullEdit ( )

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

no changes were made.

Returns
bool

Definition at line 251 of file EditResult.php.

References MediaWiki\Storage\EditResult\$isNullEdit.

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

◆ isRevert()

MediaWiki\Storage\EditResult::isRevert ( )

Whether the edit was a revert, not necessarily exact.

An edit is considered a revert if it either:

  • Restores the page to an exact previous state (rollbacks, manual reverts and some undos). E.g. for edits A B C D, edits C and D are reverted.
  • Undoes some edits made previously, but automatic conflict resolution is done and possibly additional changes are made by the reverting user (undo). E.g. for edits A B C D, edits B and C are reverted.

To check whether the edit was an exact revert, please use the isExactRevert() method. The getRevertMethod() will provide additional information about which kind of revert was made.

Returns
bool

Definition at line 217 of file EditResult.php.

References MediaWiki\Storage\EditResult\getOldestRevertedRevisionId(), and MediaWiki\Storage\EditResult\isNew().

◆ jsonSerialize()

MediaWiki\Storage\EditResult::jsonSerialize ( )

Returns an array representing the EditResult object.

See also
EditResult::newFromArray()
Returns
array

-return array{isNew:bool,originalRevisionId:bool|int,revertMethod:int|null,newestRevertedRevId:int|null,oldestRevertedRevId:int|null,isExactRevert:bool,isNullEdit:bool,revertTags:string[],version:string}

Since
1.36

Definition at line 276 of file EditResult.php.

References MediaWiki\Storage\EditResult\$isExactRevert, MediaWiki\Storage\EditResult\$isNew, MediaWiki\Storage\EditResult\$isNullEdit, MediaWiki\Storage\EditResult\$newestRevertedRevId, MediaWiki\Storage\EditResult\$oldestRevertedRevId, MediaWiki\Storage\EditResult\$originalRevisionId, MediaWiki\Storage\EditResult\$revertMethod, MediaWiki\Storage\EditResult\$revertTags, and MediaWiki\Storage\EditResult\SERIALIZATION_FORMAT_VERSION.

◆ newFromArray()

static MediaWiki\Storage\EditResult::newFromArray ( array  $a)
static

Recreate the EditResult object from its array representation.

This must ONLY be used for deserializing EditResult objects serialized using EditResult::jsonSerialize(). The structure of the array may change without prior notice.

For constructing EditResult objects from scratch use EditResultBuilder.

See also
EditResult::jsonSerialize()
Parameters
array$a-param array{isNew:bool,originalRevisionId:bool|int,revertMethod:int|null,newestRevertedRevId:int|null,oldestRevertedRevId:int|null,isExactRevert:bool,isNullEdit:bool,revertTags:string[],version:string} $a
Returns
EditResult
Since
1.36

Definition at line 125 of file EditResult.php.

Member Data Documentation

◆ $isExactRevert

bool MediaWiki\Storage\EditResult::$isExactRevert
private

◆ $isNew

bool MediaWiki\Storage\EditResult::$isNew
private

◆ $isNullEdit

bool MediaWiki\Storage\EditResult::$isNullEdit
private

◆ $newestRevertedRevId

int null MediaWiki\Storage\EditResult::$newestRevertedRevId
private

◆ $oldestRevertedRevId

int null MediaWiki\Storage\EditResult::$oldestRevertedRevId
private

◆ $originalRevisionId

bool int MediaWiki\Storage\EditResult::$originalRevisionId
private

◆ $revertMethod

int null MediaWiki\Storage\EditResult::$revertMethod
private

◆ $revertTags

string [] MediaWiki\Storage\EditResult::$revertTags
private

◆ REVERT_MANUAL

const MediaWiki\Storage\EditResult::REVERT_MANUAL = 3

◆ REVERT_ROLLBACK

const MediaWiki\Storage\EditResult::REVERT_ROLLBACK = 2

Definition at line 42 of file EditResult.php.

◆ REVERT_UNDO

const MediaWiki\Storage\EditResult::REVERT_UNDO = 1

Definition at line 41 of file EditResult.php.

◆ SERIALIZATION_FORMAT_VERSION

const MediaWiki\Storage\EditResult::SERIALIZATION_FORMAT_VERSION = '1'
private

Definition at line 45 of file EditResult.php.

Referenced by MediaWiki\Storage\EditResult\jsonSerialize().


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