MediaWiki master
MediaWiki\Page\Event\PageStateEvent Class Reference

Base class for domain events representing changes to page state. More...

Inherits MediaWiki\DomainEvent\DomainEvent.

Inherited by MediaWiki\Page\Event\PageDeletedEvent, MediaWiki\Page\Event\PageMovedEvent, and MediaWiki\Page\Event\PageRevisionUpdatedEvent.

Collaboration diagram for MediaWiki\Page\Event\PageStateEvent:

Public Member Functions

 __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.
 
 getPageRecordAfter ()
 Returns a PageRecord representing the state of the page after the change, or null if the page no longer exists after.
 
 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 TYPE = 'PageState'
 
- Public Attributes inherited from MediaWiki\DomainEvent\DomainEvent
const ANY = '*'
 

Protected Member Functions

 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

Base class for domain events representing changes to page state.

Page state events include life cycle changes to the page (e.g. create, move, delete) as well as changing a page's latest revision. They do not include changes to the page's revision history (except for changes to the latest revision).

The basic page state before and after the change is represented by PageRecord objects. However, not all changes that trigger a PageStateEvents will cause differences in the page record.

Stability: unstable
until 1.45

Definition at line 43 of file PageStateEvent.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Page\Event\PageStateEvent::__construct ( string $cause,
?ExistingPageRecord $pageRecordBefore,
?ExistingPageRecord $pageRecordAfter,
UserIdentity $performer,
array $tags = [],
array $flags = [],
$timestamp = false )
Parameters
string$causeSee the self::CAUSE_XXX constants.
?ExistingPageRecord$pageRecordBeforeThe page record before the change, or null if the page didn't exist before.
?ExistingPageRecord$pageRecordAfterThe page record after the change, or null if the page no longer exists after.
UserIdentity$performerThe user performing the update.
array<string>$tags Applicable tags, see ChangeTags.
array<string,bool>$flags See the self::FLAG_XXX constants.
string | ConvertibleTimestamp | false$timestamp

Definition at line 77 of file PageStateEvent.php.

References MediaWiki\DomainEvent\DomainEvent\declareEventType().

Member Function Documentation

◆ getCause()

MediaWiki\Page\Event\PageStateEvent::getCause ( )

Indicates the cause of the update.

See the self::CAUSE_XXX constants.

Returns
string

Definition at line 167 of file PageStateEvent.php.

◆ getPageId()

MediaWiki\Page\Event\PageStateEvent::getPageId ( )

Returns the ID of the page affected by the change.

Note that the ID may no longer be valid after the change (e.g. if the page was deleted).

Definition at line 139 of file PageStateEvent.php.

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

◆ getPageRecordAfter()

MediaWiki\Page\Event\PageStateEvent::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 in MediaWiki\Page\Event\PageDeletedEvent, MediaWiki\Page\Event\PageMovedEvent, and MediaWiki\Page\Event\PageRevisionUpdatedEvent.

Definition at line 130 of file PageStateEvent.php.

◆ getPageRecordBefore()

MediaWiki\Page\Event\PageStateEvent::getPageRecordBefore ( )

Returns a PageRecord representing the state of the page before the change, or null if the page did not exist before.

Reimplemented in MediaWiki\Page\Event\PageDeletedEvent, and MediaWiki\Page\Event\PageMovedEvent.

Definition at line 117 of file PageStateEvent.php.

◆ getPerformer()

MediaWiki\Page\Event\PageStateEvent::getPerformer ( )

Returns the user that performed the update.

For an edit, this will be the same as the user returned by getAuthor(). However, it may be a different user for update events caused e.g. by undeletion or imports.

Definition at line 150 of file PageStateEvent.php.

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

◆ getTags()

MediaWiki\Page\Event\PageStateEvent::getTags ( )

Returns any tags applied to the edit.

See also
Change tagging

Definition at line 184 of file PageStateEvent.php.

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

◆ hasCause()

MediaWiki\Page\Event\PageStateEvent::hasCause ( string $cause)

◆ hasFlag()

MediaWiki\Page\Event\PageStateEvent::hasFlag ( string $name)
protected

Checks flags describing the page update.

Use with FLAG_XXX constants declared by subclasses.

Definition at line 158 of file PageStateEvent.php.

◆ hasTag()

MediaWiki\Page\Event\PageStateEvent::hasTag ( string $name)

Checks for a tag associated the page update.

See also
Change tagging

Definition at line 193 of file PageStateEvent.php.

Member Data Documentation

◆ TYPE

const MediaWiki\Page\Event\PageStateEvent::TYPE = 'PageState'

Definition at line 45 of file PageStateEvent.php.


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