MediaWiki master
MediaWiki\Page\Event\PageRevisionUpdatedEvent Class Reference

Domain event representing a page update. More...

Inherits MediaWiki\Page\Event\PageStateEvent, and MediaWiki\Storage\PageUpdateCauses.

Collaboration diagram for MediaWiki\Page\Event\PageRevisionUpdatedEvent:

Public Member Functions

 __construct (string $cause, ?ExistingPageRecord $pageRecordBefore, ExistingPageRecord $pageRecordAfter, ?RevisionRecord $latestRevisionBefore, RevisionRecord $latestRevisionAfter, RevisionSlotsUpdate $slotsUpdate, ?EditResult $editResult, UserIdentity $performer, array $tags=[], array $flags=[], int $patrolStatus=0)
 
 changedLatestRevisionId ()
 Whether this event represents a change to the latest revision ID associated with the page.
 
 getAuthor ()
 Returns the author of the new revision.
 
 getEditResult ()
 An EditResult representing the effects of the update.
 
 getLatestRevisionAfter ()
 The revision that became the latest as a result of the update.
 
 getLatestRevisionBefore ()
 Returned the revision that used to be latest before the update.
 
 getNewRevision ()
 
 getOldRevision ()
 
 getPage ()
 Returns the page that was updated.
 
 getPageRecordAfter ()
 Returns a PageRecord representing the state of the page after the change, or null if the page no longer exists after.Note that the PageRecord returned by this method may be the same as the one returned by getPageRecordBefore(). This may be the case for reconciliation events, but also for events that represent changes that are not reflected in the PageRecord.
 
 getPatrolStatus ()
 Returns the page update's initial patrol status.
 
 getSlotsUpdate ()
 Returns which slots were changed, added, or removed by the update.
 
 isBotUpdate ()
 Whether the update was performed by a bot.
 
 isCreation ()
 Whether the updated created the page.
 
 isEffectiveContentChange ()
 Whether the update effectively changed the content of the page.
 
 isImplicit ()
 Whether the update was performed automatically without the user's initiative.
 
 isModifiedSlot (string $slotRole)
 Whether the given slot was modified by the page update.
 
 isNominalContentChange ()
 Whether the update nominally changed the content of the page.
 
 isRevert ()
 Whether the update reverts an earlier update to the same page.
 
 isSilent ()
 Whether the update should be omitted from update feeds presented to the user.
 
- Public Member Functions inherited from MediaWiki\Page\Event\PageStateEvent
 __construct (string $cause, ?ExistingPageRecord $pageRecordBefore, ?ExistingPageRecord $pageRecordAfter, UserIdentity $performer, array $tags=[], array $flags=[], $timestamp=false)
 
 getCause ()
 Indicates the cause of the update.
 
 getPageId ()
 Returns the ID of the page affected by the change.
 
 getPageRecordBefore ()
 Returns a PageRecord representing the state of the page before the change, or null if the page did not exist before.
 
 getPerformer ()
 Returns the user that performed the update.
 
 getTags ()
 Returns any tags applied to the edit.
 
 hasCause (string $cause)
 Checks whether the update had the given cause.
 
 hasTag (string $name)
 Checks for a tag associated the page update.
 
- Public Member Functions inherited from MediaWiki\DomainEvent\DomainEvent
 __construct ( $timestamp=false, bool $isReconciliationRequest=false)
 
 getEventTimestamp ()
 Returns the time at which the event was emitted.
 
 getEventType ()
 Returns this event's type.
 
 getEventTypeChain ()
 Returns the event types this event is compatible with.
 
 isReconciliationRequest ()
 Determines whether this is a reconciliation event, triggered artificially in order to give listeners an opportunity to catch up on missed events or recreate corrupted data.
 

Public Attributes

const DEFAULT_FLAGS
 All available flags and their default values.
 
const TYPE = 'PageRevisionUpdated'
 
- Public Attributes inherited from MediaWiki\Page\Event\PageStateEvent
const TYPE = 'PageState'
 
- Public Attributes inherited from MediaWiki\DomainEvent\DomainEvent
const ANY = '*'
 

Additional Inherited Members

- Protected Member Functions inherited from MediaWiki\Page\Event\PageStateEvent
 hasFlag (string $name)
 Checks flags describing the page update.
 
- Protected Member Functions inherited from MediaWiki\DomainEvent\DomainEvent
 declareEventType (string $eventType)
 Declares the event type.
 

Detailed Description

Domain event representing a page update.

A PageRevisionUpdatedEvent is triggered when a page's latest revision changes, even if the content did not change (for a dummy revision). A reconciliation version of this event may be triggered even when the page's latest version did not change (on null edits), to provide an opportunity to listeners to recover from data loss and corruption by re-generating any derived data.

PageRevisionUpdatedEvent is emitted by DerivedPageDataUpdater, typically triggered by PageUpdater. User activities that trigger a PageRevisionUpdated event include:

  • editing, including page creation and null-edits
  • moving pages
  • undeleting pages
  • importing revisions
  • Any activity that creates a dummy revision, such as changing the page's protection level.

Extensions that want to subscribe to this event should list "PageRevisionUpdated" as a subscribed event type. Subscribers based on DomainEventIngress should implement the handlePageRevisionUpdatedEvent() listener method to be informed when a page update has been committed to the database.

See the documentation of DomainEventIngress and DomainEventSource for more options and details.

Stability: unstable
until 1.45

Definition at line 60 of file PageRevisionUpdatedEvent.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Page\Event\PageRevisionUpdatedEvent::__construct ( string $cause,
?ExistingPageRecord $pageRecordBefore,
ExistingPageRecord $pageRecordAfter,
?RevisionRecord $latestRevisionBefore,
RevisionRecord $latestRevisionAfter,
RevisionSlotsUpdate $slotsUpdate,
?EditResult $editResult,
UserIdentity $performer,
array $tags = [],
array $flags = [],
int $patrolStatus = 0 )
Parameters
string$causeSee the self::CAUSE_XXX constants.
?ExistingPageRecord$pageRecordBeforeThe page record before the change.
ExistingPageRecord$pageRecordAfterThe page record after the change.
?RevisionRecord$latestRevisionBeforeThe revision that used to be the latest before the updated.
RevisionRecord$latestRevisionAfterThe revision object that became the latest as a result of the update.
RevisionSlotsUpdate$slotsUpdatePage content changed by the update.
?EditResult$editResultAn EditResult representing the effects of an edit.
UserIdentity$performerThe user performing the update.
array<string>$tags Applicable tags, see ChangeTags.
array<string,bool>$flags See the self::FLAG_XXX constants.
int$patrolStatusSee PageUpdater::setRcPatrolStatus()

Definition at line 116 of file PageRevisionUpdatedEvent.php.

References MediaWiki\DomainEvent\DomainEvent\declareEventType(), MediaWiki\Revision\RevisionRecord\getPage(), MediaWiki\Revision\RevisionRecord\getTimestamp(), and MediaWiki\Page\PageReference\isSamePageAs().

Member Function Documentation

◆ changedLatestRevisionId()

MediaWiki\Page\Event\PageRevisionUpdatedEvent::changedLatestRevisionId ( )

Whether this event represents a change to the latest revision ID associated with the page.

In other words, the page's latest revision after the change is different from the page's latest revision before the change.

This method will return true under most circumstances. It will however return false for reconciliation requests like null edits. In that case, isReconciliationRequest() should return true.

Note
Listeners should generally not use this method to check if event processing can be skipped, since that would mean ignoring reconciliation requests used to recover from data loss or corruption. The preferred way to check if processing would be redundant is isNominalContentChange().
See also
DomainEvent::isReconciliationRequest()
DomainEvent::isNominalContentChange()

Definition at line 219 of file PageRevisionUpdatedEvent.php.

Referenced by MediaWiki\RecentChanges\ChangeTrackingEventIngress\handlePageRevisionUpdatedEvent().

◆ getAuthor()

MediaWiki\Page\Event\PageRevisionUpdatedEvent::getAuthor ( )

Returns the author of the new revision.

Note that this may be different from the user returned by getPerformer() for update events caused e.g. by undeletion or imports.

Definition at line 271 of file PageRevisionUpdatedEvent.php.

◆ getEditResult()

MediaWiki\Page\Event\PageRevisionUpdatedEvent::getEditResult ( )

An EditResult representing the effects of the update.

Can be used to determine whether the edit was a revert and which edits were reverted.

This may return null for updates that do not result from edits, such as imports or undeletions.

Definition at line 300 of file PageRevisionUpdatedEvent.php.

Referenced by MediaWiki\RecentChanges\ChangeTrackingEventIngress\handlePageRevisionUpdatedEvent().

◆ getLatestRevisionAfter()

◆ getLatestRevisionBefore()

MediaWiki\Page\Event\PageRevisionUpdatedEvent::getLatestRevisionBefore ( )

Returned the revision that used to be latest before the update.

Will be null if the edit created the page. Will be the same as getLatestRevisionAfter() if the edit was a "null-edit".

Note that this is not necessarily the new revision's parent revision. For instance, when undeleting a page, getLatestRevisionBefore() will return null because the page didn't exist before, even if the undeleted page has many revisions and the new latest revision indeed has a parent revision.

The parent revision can be determined by calling getLatestRevisionAfter()->getParentId().

Definition at line 319 of file PageRevisionUpdatedEvent.php.

Referenced by MediaWiki\RecentChanges\ChangeTrackingEventIngress\handlePageRevisionUpdatedEvent(), and MediaWiki\ResourceLoader\ResourceLoaderEventIngress\handlePageRevisionUpdatedEvent().

◆ getNewRevision()

MediaWiki\Page\Event\PageRevisionUpdatedEvent::getNewRevision ( )
Deprecated
since 1.44

Definition at line 340 of file PageRevisionUpdatedEvent.php.

◆ getOldRevision()

MediaWiki\Page\Event\PageRevisionUpdatedEvent::getOldRevision ( )
Deprecated
since 1.44

Definition at line 333 of file PageRevisionUpdatedEvent.php.

◆ getPage()

MediaWiki\Page\Event\PageRevisionUpdatedEvent::getPage ( )

◆ getPageRecordAfter()

MediaWiki\Page\Event\PageRevisionUpdatedEvent::getPageRecordAfter ( )

Returns a PageRecord representing the state of the page after the change, or null if the page no longer exists after.Note that the PageRecord returned by this method may be the same as the one returned by getPageRecordBefore(). This may be the case for reconciliation events, but also for events that represent changes that are not reflected in the PageRecord.

Reimplemented from MediaWiki\Page\Event\PageStateEvent.

Definition at line 176 of file PageRevisionUpdatedEvent.php.

Referenced by MediaWiki\Search\SearchEventIngress\handlePageRevisionUpdatedEvent().

◆ getPatrolStatus()

MediaWiki\Page\Event\PageRevisionUpdatedEvent::getPatrolStatus ( )

Returns the page update's initial patrol status.

See also
PageUpdater::setRcPatrolStatus()
RecentChange::PRC_XXX

Definition at line 349 of file PageRevisionUpdatedEvent.php.

Referenced by MediaWiki\RecentChanges\ChangeTrackingEventIngress\handlePageRevisionUpdatedEvent().

◆ getSlotsUpdate()

MediaWiki\Page\Event\PageRevisionUpdatedEvent::getSlotsUpdate ( )

Returns which slots were changed, added, or removed by the update.

Definition at line 278 of file PageRevisionUpdatedEvent.php.

◆ isBotUpdate()

MediaWiki\Page\Event\PageRevisionUpdatedEvent::isBotUpdate ( )

Whether the update was performed by a bot.

Definition at line 384 of file PageRevisionUpdatedEvent.php.

Referenced by MediaWiki\RecentChanges\ChangeTrackingEventIngress\handlePageRevisionUpdatedEvent().

◆ isCreation()

MediaWiki\Page\Event\PageRevisionUpdatedEvent::isCreation ( )

Whether the updated created the page.

A deleted/archived page is not considered to "exist". When undeleting a page, the page will be restored using its old page ID, so the "created" page may have an ID that was seen previously.

Definition at line 196 of file PageRevisionUpdatedEvent.php.

◆ isEffectiveContentChange()

MediaWiki\Page\Event\PageRevisionUpdatedEvent::isEffectiveContentChange ( )

Whether the update effectively changed the content of the page.

This will return false for "dummy revisions" that represent an entry in the page history but do not modify the content. It will also be false for reconciliation events (null edits).

Note
Listeners aiming to skip processing of events that didn't change the content for optimization should use isNominalContentChange() instead. That way, they would not skip processing for reconciliation requests, providing a way to recover from data loss and corruption.
See also
isNominalContentChange()

Definition at line 260 of file PageRevisionUpdatedEvent.php.

Referenced by MediaWiki\RecentChanges\ChangeTrackingEventIngress\handlePageRevisionUpdatedEvent().

◆ isImplicit()

MediaWiki\Page\Event\PageRevisionUpdatedEvent::isImplicit ( )

Whether the update was performed automatically without the user's initiative.

Definition at line 365 of file PageRevisionUpdatedEvent.php.

Referenced by MediaWiki\RecentChanges\ChangeTrackingEventIngress\handlePageRevisionUpdatedEvent().

◆ isModifiedSlot()

MediaWiki\Page\Event\PageRevisionUpdatedEvent::isModifiedSlot ( string $slotRole)

Whether the given slot was modified by the page update.

Slots that were removed do not count as modified. This is a convenience method for $this->getSlotsUpdate()->isModifiedSlot( $slotRole ).

Definition at line 288 of file PageRevisionUpdatedEvent.php.

Referenced by MediaWiki\Languages\LanguageEventIngress\handlePageRevisionUpdatedEvent(), and MediaWiki\Search\SearchEventIngress\handlePageRevisionUpdatedEvent().

◆ isNominalContentChange()

MediaWiki\Page\Event\PageRevisionUpdatedEvent::isNominalContentChange ( )

Whether the update nominally changed the content of the page.

This is the case if:

  • the update actually changed the page's content, see isEffectiveContentChange().
  • the event is a reconciliation request, see isReconciliationRequest().

On other words, this will return true for actual changes and null edits, but will return false for "dummy revisions".

Note
This is preferred over isEffectiveContentChange() for listeners aiming to avoid redundant processing when the content didn't change. The purpose of reconciliation requests is to re-trigger such processing to recover from data loss and corruption, even when there was no actual change in content.
See also
isEffectiveContentChange()
DomainEvent::isReconciliationRequest()

Definition at line 242 of file PageRevisionUpdatedEvent.php.

Referenced by MediaWiki\ResourceLoader\ResourceLoaderEventIngress\handlePageRevisionUpdatedEvent().

◆ isRevert()

MediaWiki\Page\Event\PageRevisionUpdatedEvent::isRevert ( )

Whether the update reverts an earlier update to the same page.

Note that an "undo" style revert may create a new revision that is different from any previous revision by applying the inverse of a past update to the latest revision.

See also
EditResult::isRevert

Definition at line 377 of file PageRevisionUpdatedEvent.php.

Referenced by MediaWiki\RecentChanges\ChangeTrackingEventIngress\handlePageRevisionUpdatedEvent().

◆ isSilent()

MediaWiki\Page\Event\PageRevisionUpdatedEvent::isSilent ( )

Whether the update should be omitted from update feeds presented to the user.

Definition at line 357 of file PageRevisionUpdatedEvent.php.

Referenced by MediaWiki\RecentChanges\ChangeTrackingEventIngress\handlePageRevisionUpdatedEvent().

Member Data Documentation

◆ DEFAULT_FLAGS

const MediaWiki\Page\Event\PageRevisionUpdatedEvent::DEFAULT_FLAGS
Initial value:
= [
self::FLAG_SILENT => false,
self::FLAG_BOT => false,
self::FLAG_IMPLICIT => false,
]

All available flags and their default values.

Definition at line 87 of file PageRevisionUpdatedEvent.php.

◆ TYPE

const MediaWiki\Page\Event\PageRevisionUpdatedEvent::TYPE = 'PageRevisionUpdated'

Definition at line 62 of file PageRevisionUpdatedEvent.php.


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