MediaWiki  master
MediaWiki\Storage\DerivedPageDataUpdater Class Reference

A handle for managing updates for derived page data on edit, import, purge, etc. More...

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

Public Member Functions

 __construct (WikiPage $wikiPage, RevisionStore $revisionStore, RevisionRenderer $revisionRenderer, SlotRoleRegistry $slotRoleRegistry, ParserCache $parserCache, JobQueueGroup $jobQueueGroup, MessageCache $messageCache, Language $contLang, ILBFactory $loadbalancerFactory, IContentHandlerFactory $contentHandlerFactory, HookContainer $hookContainer, EditResultCache $editResultCache, UserNameUtils $userNameUtils, ContentTransformer $contentTransformer, PageEditStash $pageEditStash, TalkPageNotificationManager $talkPageNotificationManager, WANObjectCache $mainWANObjectCache, PermissionManager $permissionManager)
 
 doParserCacheUpdate ()
 
 doSecondaryDataUpdates (array $options=[])
 Do secondary data updates (e.g. More...
 
 doUpdates ()
 Do standard updates after page edit, purge, or import. More...
 
 getCanonicalParserOptions ()
 
 getCanonicalParserOutput ()
 Returns the canonical parser output.Code that does not need access to the rendered HTML should use getParserOutputForMetaData() instead.
Returns
ParserOutput
More...
 
 getModifiedSlotRoles ()
 Returns the role names of the slots modified by the new revision, not including removed roles. More...
 
 getPage ()
 Returns the page being updated. More...
 
 getParserOutputForMetaData ()
 
 getPreparedEdit ()
 
 getRawContent (string $role)
 Returns the content of the given slot, with no audience checks. More...
 
 getRawSlot ( $role)
 Returns the slot, modified or inherited, after PST, with no audience checks applied. More...
 
 getRemovedSlotRoles ()
 Returns the role names of the slots removed by the new revision. More...
 
 getRenderedRevision ()
 
 getRevision ()
 Returns the update's target revision - that is, the revision that will be the current revision after the update. More...
 
 getSecondaryDataUpdates ( $recursive=false)
 
 getSlotParserOutput ( $role, $generateHtml=true)
 
 getSlots ()
 Returns the slots of the target revision, after PST. More...
 
 getTouchedSlotRoles ()
 Returns the role names of the slots touched by the new revision, including removed roles. More...
 
 grabCurrentRevision ()
 Returns the revision that was the page's current revision when grabCurrentRevision() was first called. More...
 
 isChange ()
 Whether the content of the current revision after the edit is different from the content of the current revision before the edit. More...
 
 isContentDeleted ()
 Whether the content is deleted and thus not visible to the public. More...
 
 isContentPrepared ()
 Whether prepareUpdate() or prepareContent() have been called on this instance. More...
 
 isCountable ()
 
 isCreation ()
 Whether the edit creates the page. More...
 
 isRedirect ()
 
 isReusableFor (UserIdentity $user=null, RevisionRecord $revision=null, RevisionSlotsUpdate $slotsUpdate=null, $parentId=null)
 Checks whether this DerivedPageDataUpdater can be re-used for running updates targeting the given revision. More...
 
 isUpdatePrepared ()
 Whether prepareUpdate() has been called on this instance. More...
 
 pageExisted ()
 Determines whether the page being edited already existed. More...
 
 prepareContent (UserIdentity $user, RevisionSlotsUpdate $slotsUpdate, $useStash=true)
 Prepare updates based on an update which has not yet been saved. More...
 
 prepareUpdate (RevisionRecord $revision, array $options=[])
 Prepare derived data updates targeting the given RevisionRecord. More...
 
 setArticleCountMethod ( $articleCountMethod)
 
 setForceEmptyRevision (bool $forceEmptyRevision)
 Set whether null-edits should create a revision. More...
 
 setLogger (LoggerInterface $logger)
 
 setRcWatchCategoryMembership ( $rcWatchCategoryMembership)
 
 wasRedirect ()
 Whether the page was a redirect before the edit. More...
 

Private Member Functions

 assertHasPageState ( $method)
 
 assertHasRevision ( $method)
 
 assertPrepared ( $method)
 
 assertTransition ( $newStage)
 Asserts that a transition to the given stage is possible, without performing it. More...
 
 doTransition ( $newStage)
 Transition function for managing the life cycle of this instances. More...
 
 getContentHandler ( $role)
 
 getContentModel ( $role)
 Returns the content model of the given slot. More...
 
 getPageId ()
 
 getParentRevision ()
 Returns the parent revision of the new revision wrapped by this update. More...
 
 getRevisionSlotsUpdate ()
 Returns the RevisionSlotsUpdate for this updater. More...
 
 getTitle ()
 
 getWikiPage ()
 
 maybeEnqueueRevertedTagUpdateJob ()
 If the edit was a revert and it is considered "approved", enqueues the RevertedTagUpdateJob for it. More...
 
 revisionIsRedirect (RevisionRecord $rev)
 
 shouldGenerateHTMLOnEdit ()
 
 triggerParserCacheUpdate ()
 
 usePrimary ()
 

Private Attributes

string $articleCountMethod
 see $wgArticleCountMethod More...
 
IContentHandlerFactory $contentHandlerFactory
 
ContentTransformer $contentTransformer
 
Language $contLang
 
EditResultCache $editResultCache
 
bool $forceEmptyRevision = false
 Whether null-edits create a revision. More...
 
HookRunner $hookRunner
 
JobQueueGroup $jobQueueGroup
 
ILBFactory $loadbalancerFactory
 
LoggerInterface $logger
 
WANObjectCache $mainWANObjectCache
 
MessageCache $messageCache
 
 $options
 Stores (most of) the $options parameter of prepareUpdate(). More...
 
PageEditStash $pageEditStash
 
array $pageState = null
 The state of the relevant row in page table before the edit. More...
 
RevisionRecord null $parentRevision = null
 
ParserCache $parserCache
 
PermissionManager $permissionManager
 
bool $rcWatchCategoryMembership = false
 see $wgRCWatchCategoryMembership More...
 
RenderedRevision $renderedRevision = null
 
RevisionRecord null $revision = null
 
RevisionRenderer $revisionRenderer
 
RevisionStore $revisionStore
 
SlotRoleRegistry $slotRoleRegistry
 
RevisionSlotsUpdate null $slotsUpdate = null
 
string $stage = 'new'
 A stage identifier for managing the life cycle of this instance. More...
 
TalkPageNotificationManager $talkPageNotificationManager
 
UserIdentity null $user = null
 
UserNameUtils $userNameUtils
 
WikiPage $wikiPage
 

Additional Inherited Members

- Public Attributes inherited from IDBAccessObject
const READ_NONE = -1
 Constants for object loading bitfield flags (higher => higher QoS) More...
 

Detailed Description

A handle for managing updates for derived page data on edit, import, purge, etc.

Note
Avoid direct usage of DerivedPageDataUpdater.
Todo:
Define interfaces for the different use cases of DerivedPageDataUpdater, particularly providing access to post-PST content and ParserOutput to callbacks during revision creation, which currently use WikiPage::prepareContentForEdit, and allowing updates to be triggered on purge, import, and undeletion, which currently use WikiPage::doEditUpdates() and Content::getSecondaryDataUpdates().

DerivedPageDataUpdater instances are designed to be cached inside a WikiPage instance, and re-used by callback code over the course of an update operation. It's a stepping stone on the way to a more complete refactoring of WikiPage.

When using a DerivedPageDataUpdater, the following life cycle must be observed: grabCurrentRevision (optional), prepareContent (optional), prepareUpdate (required for doUpdates). getCanonicalParserOutput, getSlots, and getSecondaryDataUpdates require prepareContent or prepareUpdate to have been called first, to initialize the DerivedPageDataUpdater.

See also
docs/pageupdater.md for more information.

MCR migration note: this replaces the relevant methods in WikiPage, and covers the use cases of PreparedEdit.

Access: internal
Since
1.32

Definition at line 106 of file DerivedPageDataUpdater.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Storage\DerivedPageDataUpdater::__construct ( WikiPage  $wikiPage,
RevisionStore  $revisionStore,
RevisionRenderer  $revisionRenderer,
SlotRoleRegistry  $slotRoleRegistry,
ParserCache  $parserCache,
JobQueueGroup  $jobQueueGroup,
MessageCache  $messageCache,
Language  $contLang,
ILBFactory  $loadbalancerFactory,
IContentHandlerFactory  $contentHandlerFactory,
HookContainer  $hookContainer,
EditResultCache  $editResultCache,
UserNameUtils  $userNameUtils,
ContentTransformer  $contentTransformer,
PageEditStash  $pageEditStash,
TalkPageNotificationManager  $talkPageNotificationManager,
WANObjectCache  $mainWANObjectCache,
PermissionManager  $permissionManager 
)
Parameters
WikiPage$wikiPage
RevisionStore$revisionStore
RevisionRenderer$revisionRenderer
SlotRoleRegistry$slotRoleRegistry
ParserCache$parserCache
JobQueueGroup$jobQueueGroup
MessageCache$messageCache
Language$contLang
ILBFactory$loadbalancerFactory
IContentHandlerFactory$contentHandlerFactory
HookContainer$hookContainer
EditResultCache$editResultCache
UserNameUtils$userNameUtils
ContentTransformer$contentTransformer
PageEditStash$pageEditStash
TalkPageNotificationManager$talkPageNotificationManager
WANObjectCache$mainWANObjectCache
PermissionManager$permissionManager

Definition at line 336 of file DerivedPageDataUpdater.php.

References MediaWiki\Storage\DerivedPageDataUpdater\$contentHandlerFactory, MediaWiki\Storage\DerivedPageDataUpdater\$contentTransformer, MediaWiki\Storage\DerivedPageDataUpdater\$contLang, MediaWiki\Storage\DerivedPageDataUpdater\$editResultCache, MediaWiki\Storage\DerivedPageDataUpdater\$jobQueueGroup, MediaWiki\Storage\DerivedPageDataUpdater\$loadbalancerFactory, MediaWiki\Storage\DerivedPageDataUpdater\$mainWANObjectCache, MediaWiki\Storage\DerivedPageDataUpdater\$messageCache, MediaWiki\Storage\DerivedPageDataUpdater\$pageEditStash, MediaWiki\Storage\DerivedPageDataUpdater\$parserCache, MediaWiki\Storage\DerivedPageDataUpdater\$permissionManager, MediaWiki\Storage\DerivedPageDataUpdater\$revisionRenderer, MediaWiki\Storage\DerivedPageDataUpdater\$revisionStore, MediaWiki\Storage\DerivedPageDataUpdater\$slotRoleRegistry, MediaWiki\Storage\DerivedPageDataUpdater\$talkPageNotificationManager, MediaWiki\Storage\DerivedPageDataUpdater\$userNameUtils, and MediaWiki\Storage\DerivedPageDataUpdater\$wikiPage.

Member Function Documentation

◆ assertHasPageState()

MediaWiki\Storage\DerivedPageDataUpdater::assertHasPageState (   $method)
private

Definition at line 1016 of file DerivedPageDataUpdater.php.

◆ assertHasRevision()

MediaWiki\Storage\DerivedPageDataUpdater::assertHasRevision (   $method)
private

Definition at line 1033 of file DerivedPageDataUpdater.php.

◆ assertPrepared()

MediaWiki\Storage\DerivedPageDataUpdater::assertPrepared (   $method)
private

Definition at line 1025 of file DerivedPageDataUpdater.php.

◆ assertTransition()

MediaWiki\Storage\DerivedPageDataUpdater::assertTransition (   $newStage)
private

Asserts that a transition to the given stage is possible, without performing it.

See also
docs/pageupdater.md for documentation of the life cycle.
Parameters
string$newStage
Exceptions
LogicExceptionIf this instance is not in the expected stage

Definition at line 414 of file DerivedPageDataUpdater.php.

Referenced by MediaWiki\Storage\DerivedPageDataUpdater\doTransition().

◆ doParserCacheUpdate()

MediaWiki\Storage\DerivedPageDataUpdater::doParserCacheUpdate ( )

Definition at line 1789 of file DerivedPageDataUpdater.php.

References WikiPage\getId().

◆ doSecondaryDataUpdates()

MediaWiki\Storage\DerivedPageDataUpdater::doSecondaryDataUpdates ( array  $options = [])

Do secondary data updates (e.g.

updating link tables) or schedule them as deferred updates

MCR note: this method is temporarily exposed via WikiPage::doSecondaryDataUpdates.

Parameters
array$options
  • recursive: make the update recursive, i.e. also update pages which transclude the current page or otherwise depend on it (default: false)
  • defer: one of the DeferredUpdates constants, or false to run immediately after waiting for replication of the changes from the SecondaryDataUpdates hooks (default: false)
Since
1.32

Definition at line 1752 of file DerivedPageDataUpdater.php.

References DeferredUpdates\addUpdate(), and DeferredUpdates\attemptUpdate().

◆ doTransition()

MediaWiki\Storage\DerivedPageDataUpdater::doTransition (   $newStage)
private

Transition function for managing the life cycle of this instances.

See also
docs/pageupdater.md for documentation of the life cycle.
Parameters
string$newStage
Returns
string the previous stage
Exceptions
LogicExceptionIf a transition to the given stage is not possible in the current stage.

Definition at line 396 of file DerivedPageDataUpdater.php.

References MediaWiki\Storage\DerivedPageDataUpdater\$stage, and MediaWiki\Storage\DerivedPageDataUpdater\assertTransition().

◆ doUpdates()

MediaWiki\Storage\DerivedPageDataUpdater::doUpdates ( )

Do standard updates after page edit, purge, or import.

Update links tables, site stats, search index, title cache, message cache, etc. Purges pages that depend on this page when appropriate. With a 10% chance, triggers pruning the recent changes table.

Note
prepareUpdate() must be called before calling this method!

MCR migration note: this replaces WikiPage::doEditUpdates.

Definition at line 1544 of file DerivedPageDataUpdater.php.

References $title, DeferredUpdates\addCallableUpdate(), DeferredUpdates\addUpdate(), SiteStatsUpdate\factory(), getTitle(), ResourceLoaderWikiModule\invalidateModuleCache(), User\newFromName(), CategoryMembershipChangeJob\newSpec(), NS_MEDIAWIKI, NS_USER_TALK, WikiPage\onArticleCreate(), WikiPage\onArticleEdit(), and wfDebug().

◆ getCanonicalParserOptions()

MediaWiki\Storage\DerivedPageDataUpdater::getCanonicalParserOptions ( )
Returns
ParserOptions

Definition at line 1428 of file DerivedPageDataUpdater.php.

◆ getCanonicalParserOutput()

MediaWiki\Storage\DerivedPageDataUpdater::getCanonicalParserOutput ( )

Returns the canonical parser output.Code that does not need access to the rendered HTML should use getParserOutputForMetaData() instead.

Returns
ParserOutput

Returns
ParserOutput

Implements MediaWiki\Storage\PreparedUpdate.

Definition at line 1421 of file DerivedPageDataUpdater.php.

◆ getContentHandler()

MediaWiki\Storage\DerivedPageDataUpdater::getContentHandler (   $role)
private
Parameters
string$roleslot role name
Returns
ContentHandler
Exceptions
MWUnknownContentModelException

Definition at line 723 of file DerivedPageDataUpdater.php.

◆ getContentModel()

MediaWiki\Storage\DerivedPageDataUpdater::getContentModel (   $role)
private

Returns the content model of the given slot.

Parameters
string$roleslot role name
Returns
string

Definition at line 714 of file DerivedPageDataUpdater.php.

◆ getModifiedSlotRoles()

MediaWiki\Storage\DerivedPageDataUpdater::getModifiedSlotRoles ( )

Returns the role names of the slots modified by the new revision, not including removed roles.

Returns
string[]

Implements MediaWiki\Storage\PreparedUpdate.

Definition at line 1136 of file DerivedPageDataUpdater.php.

◆ getPage()

MediaWiki\Storage\DerivedPageDataUpdater::getPage ( )

Returns the page being updated.

Since
1.37
Returns
PageIdentity

Implements MediaWiki\Storage\PreparedUpdate.

Definition at line 546 of file DerivedPageDataUpdater.php.

◆ getPageId()

MediaWiki\Storage\DerivedPageDataUpdater::getPageId ( )
private
Returns
int

Definition at line 664 of file DerivedPageDataUpdater.php.

◆ getParentRevision()

MediaWiki\Storage\DerivedPageDataUpdater::getParentRevision ( )
private

Returns the parent revision of the new revision wrapped by this update.

If the update is a null-edit, this will return the parent of the current (and new) revision. This will return null if the revision wrapped by this update created the page. Only defined after calling prepareContent() or prepareUpdate()!

Returns
RevisionRecord|null the parent revision of the new revision, or null if the update created the page.

Definition at line 572 of file DerivedPageDataUpdater.php.

◆ getParserOutputForMetaData()

MediaWiki\Storage\DerivedPageDataUpdater::getParserOutputForMetaData ( )
Since
1.37
Returns
ParserOutput

Implements MediaWiki\Storage\PreparedUpdate.

Definition at line 1413 of file DerivedPageDataUpdater.php.

◆ getPreparedEdit()

MediaWiki\Storage\DerivedPageDataUpdater::getPreparedEdit ( )
Deprecated:
This only exists for B/C, use the getters on DerivedPageDataUpdater directly!
Returns
PreparedEdit

Definition at line 1377 of file DerivedPageDataUpdater.php.

◆ getRawContent()

MediaWiki\Storage\DerivedPageDataUpdater::getRawContent ( string  $role)

Returns the content of the given slot, with no audience checks.

Exceptions
PageUpdateExceptionIf the slot is neither set for update nor inherited from the parent revision.
Parameters
string$roleslot role name
Returns
Content

Implements MediaWiki\Storage\PreparedUpdate.

Definition at line 704 of file DerivedPageDataUpdater.php.

◆ getRawSlot()

MediaWiki\Storage\DerivedPageDataUpdater::getRawSlot (   $role)

Returns the slot, modified or inherited, after PST, with no audience checks applied.

Parameters
string$roleslot role name
Exceptions
PageUpdateExceptionIf the slot is neither set for update nor inherited from the parent revision.
Returns
SlotRecord

Definition at line 692 of file DerivedPageDataUpdater.php.

◆ getRemovedSlotRoles()

MediaWiki\Storage\DerivedPageDataUpdater::getRemovedSlotRoles ( )

Returns the role names of the slots removed by the new revision.

Returns
string[]

Implements MediaWiki\Storage\PreparedUpdate.

Definition at line 1145 of file DerivedPageDataUpdater.php.

◆ getRenderedRevision()

MediaWiki\Storage\DerivedPageDataUpdater::getRenderedRevision ( )
Returns
RenderedRevision

Implements MediaWiki\Storage\PreparedUpdate.

Definition at line 1010 of file DerivedPageDataUpdater.php.

◆ getRevision()

MediaWiki\Storage\DerivedPageDataUpdater::getRevision ( )

Returns the update's target revision - that is, the revision that will be the current revision after the update.

Note
Callers must treat the returned RevisionRecord's content as immutable, even if it is a MutableRevisionRecord instance. Other aspects of a MutableRevisionRecord returned from here, such as the user or the comment, may be changed, but may not be reflected in ParserOutput until after prepareUpdate() has been called.
Todo:
This is currently used by PageUpdater::makeNewRevision() to construct an unsaved MutableRevisionRecord instance. Introduce something like an UnsavedRevisionFactory service for that purpose instead!
Returns
RevisionRecord

Implements MediaWiki\Storage\PreparedUpdate.

Definition at line 1002 of file DerivedPageDataUpdater.php.

◆ getRevisionSlotsUpdate()

MediaWiki\Storage\DerivedPageDataUpdater::getRevisionSlotsUpdate ( )
private

Returns the RevisionSlotsUpdate for this updater.

Returns
RevisionSlotsUpdate

Definition at line 1107 of file DerivedPageDataUpdater.php.

◆ getSecondaryDataUpdates()

MediaWiki\Storage\DerivedPageDataUpdater::getSecondaryDataUpdates (   $recursive = false)
Parameters
bool$recursive
Returns
DeferrableUpdate[]

Definition at line 1437 of file DerivedPageDataUpdater.php.

References $content, $title, WikiPage\exists(), WikiPage\getTitle(), and WikiPage\loadPageData().

◆ getSlotParserOutput()

MediaWiki\Storage\DerivedPageDataUpdater::getSlotParserOutput (   $role,
  $generateHtml = true 
)
Parameters
string$role
bool$generateHtml
Returns
ParserOutput

Definition at line 1402 of file DerivedPageDataUpdater.php.

◆ getSlots()

MediaWiki\Storage\DerivedPageDataUpdater::getSlots ( )

Returns the slots of the target revision, after PST.

Note
Callers must treat the returned RevisionSlots instance as immutable, even if it is a MutableRevisionSlots instance.
Returns
RevisionSlots

Definition at line 1097 of file DerivedPageDataUpdater.php.

◆ getTitle()

MediaWiki\Storage\DerivedPageDataUpdater::getTitle ( )
private
Returns
Title

Definition at line 528 of file DerivedPageDataUpdater.php.

◆ getTouchedSlotRoles()

MediaWiki\Storage\DerivedPageDataUpdater::getTouchedSlotRoles ( )

Returns the role names of the slots touched by the new revision, including removed roles.

Returns
string[]

Definition at line 1126 of file DerivedPageDataUpdater.php.

◆ getWikiPage()

MediaWiki\Storage\DerivedPageDataUpdater::getWikiPage ( )
private

◆ grabCurrentRevision()

MediaWiki\Storage\DerivedPageDataUpdater::grabCurrentRevision ( )

Returns the revision that was the page's current revision when grabCurrentRevision() was first called.

During an edit, that revision will act as the logical parent of the new revision.

Some updates are performed based on the difference between the database state at the moment this method is first called, and the state after the edit.

See also
docs/pageupdater.md for more information on when thie method can and should be called.
Note
After prepareUpdate() was called, grabCurrentRevision() will throw an exception to avoid confusion, since the page's current revision is then the new revision after the edit, which was presumably passed to prepareUpdate() as the $revision parameter. Use getParentRevision() instead to access the revision that is the parent of the new revision.
Returns
RevisionRecord|null the page's current revision, or null if the page does not yet exist.

Definition at line 614 of file DerivedPageDataUpdater.php.

References WikiPage\getRevisionRecord(), WikiPage\isCountable(), WikiPage\isRedirect(), and WikiPage\loadPageData().

◆ isChange()

MediaWiki\Storage\DerivedPageDataUpdater::isChange ( )

Whether the content of the current revision after the edit is different from the content of the current revision before the edit.

This will return false for a null-edit (no revision created), as well as for a dummy revision (a "null-revision" that has the same content as its parent).

Warning
at present, dummy revision would return false after prepareContent(), but true after prepareUpdate()!
Todo:
This should probably be fixed.
Returns
bool

Definition at line 1063 of file DerivedPageDataUpdater.php.

◆ isContentDeleted()

MediaWiki\Storage\DerivedPageDataUpdater::isContentDeleted ( )

Whether the content is deleted and thus not visible to the public.

Returns
bool

Definition at line 674 of file DerivedPageDataUpdater.php.

References MediaWiki\Revision\RevisionRecord\DELETED_TEXT.

◆ isContentPrepared()

MediaWiki\Storage\DerivedPageDataUpdater::isContentPrepared ( )

Whether prepareUpdate() or prepareContent() have been called on this instance.

Returns
bool

Definition at line 646 of file DerivedPageDataUpdater.php.

◆ isCountable()

MediaWiki\Storage\DerivedPageDataUpdater::isCountable ( )
Returns
bool

Implements MediaWiki\Storage\PreparedUpdate.

Definition at line 736 of file DerivedPageDataUpdater.php.

◆ isCreation()

MediaWiki\Storage\DerivedPageDataUpdater::isCreation ( )

Whether the edit creates the page.

Returns
bool

Definition at line 1046 of file DerivedPageDataUpdater.php.

◆ isRedirect()

MediaWiki\Storage\DerivedPageDataUpdater::isRedirect ( )
Returns
bool

Implements MediaWiki\Storage\PreparedUpdate.

Definition at line 781 of file DerivedPageDataUpdater.php.

◆ isReusableFor()

MediaWiki\Storage\DerivedPageDataUpdater::isReusableFor ( UserIdentity  $user = null,
RevisionRecord  $revision = null,
RevisionSlotsUpdate  $slotsUpdate = null,
  $parentId = null 
)

Checks whether this DerivedPageDataUpdater can be re-used for running updates targeting the given revision.

Parameters
UserIdentity | null$userThe user creating the revision in question
RevisionRecord | null$revisionNew revision (after save, if already saved)
RevisionSlotsUpdate | null$slotsUpdateNew content (before PST)
null | int$parentIdParent revision of the edit (use 0 for page creation)
Returns
bool

Definition at line 431 of file DerivedPageDataUpdater.php.

References MediaWiki\Storage\DerivedPageDataUpdater\$revision, MediaWiki\Storage\DerivedPageDataUpdater\$slotsUpdate, MediaWiki\Storage\DerivedPageDataUpdater\$user, MediaWiki\Revision\RevisionRecord\getId(), MediaWiki\User\UserIdentity\getName(), MediaWiki\Revision\RevisionRecord\getParentId(), MediaWiki\Revision\RevisionRecord\getSlots(), and MediaWiki\Storage\RevisionSlotsUpdate\hasSameUpdates().

◆ isUpdatePrepared()

MediaWiki\Storage\DerivedPageDataUpdater::isUpdatePrepared ( )

Whether prepareUpdate() has been called on this instance.

Note
will also return null in case of a null-edit!
Returns
bool

Definition at line 657 of file DerivedPageDataUpdater.php.

◆ maybeEnqueueRevertedTagUpdateJob()

MediaWiki\Storage\DerivedPageDataUpdater::maybeEnqueueRevertedTagUpdateJob ( )
private

If the edit was a revert and it is considered "approved", enqueues the RevertedTagUpdateJob for it.

If the edit is not yet approved, the EditResult is persisted in cache for later use.

Definition at line 1713 of file DerivedPageDataUpdater.php.

References RevertedTagUpdateJob\newSpec().

◆ pageExisted()

MediaWiki\Storage\DerivedPageDataUpdater::pageExisted ( )

Determines whether the page being edited already existed.

Only defined after calling grabCurrentRevision() or prepareContent() or prepareUpdate()!

Returns
bool
Exceptions
LogicExceptionif called before grabCurrentRevision

Definition at line 557 of file DerivedPageDataUpdater.php.

◆ prepareContent()

MediaWiki\Storage\DerivedPageDataUpdater::prepareContent ( UserIdentity  $user,
RevisionSlotsUpdate  $slotsUpdate,
  $useStash = true 
)

Prepare updates based on an update which has not yet been saved.

This may be used to create derived data that is needed when creating a new revision; particularly, this makes available the slots of the new revision via the getSlots() method, after applying PST and slot inheritance.

The derived data prepared for revision creation may then later be re-used by doUpdates(), without the need to re-calculate.

See also
docs/pageupdater.md for more information on when thie method can and should be called.
Note
Calling this method more than once with the same $slotsUpdate has no effect. Calling this method multiple times with different content will cause an exception.
Calling this method after prepareUpdate() has been called will cause an exception.
Parameters
UserIdentity$userThe user to act as context for pre-save transformation (PST).
RevisionSlotsUpdate$slotsUpdateThe new content of the slots to be updated by this edit, before PST.
bool$useStashWhether to use stashed ParserOutput

Definition at line 824 of file DerivedPageDataUpdater.php.

References $title, Title\equals(), MediaWiki\Storage\RevisionSlotsUpdate\getModifiedRoles(), MediaWiki\Storage\RevisionSlotsUpdate\getModifiedSlot(), MediaWiki\User\UserIdentity\getName(), MediaWiki\Storage\RevisionSlotsUpdate\getRemovedRoles(), getTitle(), MediaWiki\Storage\RevisionSlotsUpdate\isModifiedSlot(), and ParserOptions\newFromUserAndLang().

◆ prepareUpdate()

MediaWiki\Storage\DerivedPageDataUpdater::prepareUpdate ( RevisionRecord  $revision,
array  $options = [] 
)

Prepare derived data updates targeting the given RevisionRecord.

Calling this method requires the given revision to be present in the database. This may be right after a new revision has been created, or when re-generating derived data e.g. in ApiPurge, RefreshLinksJob, and the refreshLinks script.

See also
docs/pageupdater.md for more information on when thie method can and should be called.
Note
Calling this method more than once with the same revision has no effect. $options are only used for the first call. Calling this method multiple times with different revisions will cause an exception.
If grabCurrentRevision() (or prepareContent()) has been called before calling this method, $revision->getParentRevision() has to refer to the revision that was the current revision at the time grabCurrentRevision() was called.
Parameters
RevisionRecord$revision
array$optionsArray of options, following indexes are used:
  • changed: bool, whether the revision changed the content (default true)
  • created: bool, whether the revision created the page (default false)
  • moved: bool, whether the page was moved (default false)
  • oldtitle: PageIdentity, if the page was moved this is the source title (default null)
  • restored: bool, whether the page was undeleted (default false)
  • oldrevision: RevisionRecord object for the pre-update revision (default null)
  • triggeringUser: The user triggering the update (UserIdentity, defaults to the user who created the revision)
  • oldredirect: bool, null, or string 'no-change' (default null):
    • bool: whether the page was counted as a redirect before that revision, only used in changed is true and created is false
    • null or 'no-change': don't update the redirect status.
  • oldcountable: bool, null, or string 'no-change' (default null):
    • bool: whether the page was counted as an article before that revision, only used in changed is true and created is false
    • null: if created is false, don't update the article count; if created is true, do update the article count
    • 'no-change': don't update the article count, ever When set to null, pageState['oldCountable'] will be used instead if available.
  • causeAction: an arbitrary string identifying the reason for the update. See DataUpdate::getCauseAction(). (default 'unknown')
  • causeAgent: name of the user who caused the update. See DataUpdate::getCauseAgent(). (string, default 'unknown')
  • known-revision-output: a combined canonical ParserOutput for the revision, perhaps from some cache. The caller is responsible for ensuring that the ParserOutput indeed matched the $rev and $options. This mechanism is intended as a temporary stop-gap, for the time until caches have been changed to store RenderedRevision states instead of ParserOutput objects. (default: null) (since 1.33)
  • editResult: EditResult object created during the update. Required to perform reverted tag update using RevertedTagUpdateJob. (default: null) (since 1.36)
  • approved: whether the edit is somehow "approved" and the RevertedTagUpdateJob should be scheduled right away. Required only if EditResult::isRevert() is true. (boolean, default: false) (since 1.36)

Definition at line 1203 of file DerivedPageDataUpdater.php.

References MediaWiki\Revision\RevisionRecord\getId(), MediaWiki\Revision\RevisionRecord\getParentId(), MediaWiki\Revision\RevisionRecord\getSlots(), and MediaWiki\Revision\RevisionRecord\getUser().

◆ revisionIsRedirect()

MediaWiki\Storage\DerivedPageDataUpdater::revisionIsRedirect ( RevisionRecord  $rev)
private
Parameters
RevisionRecord$rev
Returns
bool

Definition at line 794 of file DerivedPageDataUpdater.php.

References MediaWiki\Revision\RevisionRecord\getContent().

◆ setArticleCountMethod()

MediaWiki\Storage\DerivedPageDataUpdater::setArticleCountMethod (   $articleCountMethod)
Parameters
string$articleCountMethod"any" or "link".
See also
$wgArticleCountMethod

Definition at line 513 of file DerivedPageDataUpdater.php.

References MediaWiki\Storage\DerivedPageDataUpdater\$articleCountMethod.

◆ setForceEmptyRevision()

MediaWiki\Storage\DerivedPageDataUpdater::setForceEmptyRevision ( bool  $forceEmptyRevision)

Set whether null-edits should create a revision.

Enabling this allows the creation of dummy revisions ("null revisions") to mark events such as renaming in the page history.

Must not be called once prepareContent() or prepareUpdate() have been called.

Since
1.38
See also
PageUpdater setForceEmptyRevision
Parameters
bool$forceEmptyRevision

Definition at line 501 of file DerivedPageDataUpdater.php.

References MediaWiki\Storage\DerivedPageDataUpdater\$forceEmptyRevision.

◆ setLogger()

MediaWiki\Storage\DerivedPageDataUpdater::setLogger ( LoggerInterface  $logger)

◆ setRcWatchCategoryMembership()

MediaWiki\Storage\DerivedPageDataUpdater::setRcWatchCategoryMembership (   $rcWatchCategoryMembership)
Parameters
bool$rcWatchCategoryMembership
See also
$wgRCWatchCategoryMembership

Definition at line 521 of file DerivedPageDataUpdater.php.

References MediaWiki\Storage\DerivedPageDataUpdater\$rcWatchCategoryMembership.

◆ shouldGenerateHTMLOnEdit()

MediaWiki\Storage\DerivedPageDataUpdater::shouldGenerateHTMLOnEdit ( )
private
Returns
bool true if at least one of slots require rendering HTML on edit, false otherwise. This is needed for example in populating ParserCache.

Definition at line 1523 of file DerivedPageDataUpdater.php.

◆ triggerParserCacheUpdate()

MediaWiki\Storage\DerivedPageDataUpdater::triggerParserCacheUpdate ( )
private

◆ usePrimary()

MediaWiki\Storage\DerivedPageDataUpdater::usePrimary ( )
private

Definition at line 728 of file DerivedPageDataUpdater.php.

◆ wasRedirect()

MediaWiki\Storage\DerivedPageDataUpdater::wasRedirect ( )

Whether the page was a redirect before the edit.

Returns
bool

Definition at line 1073 of file DerivedPageDataUpdater.php.

Member Data Documentation

◆ $articleCountMethod

string MediaWiki\Storage\DerivedPageDataUpdater::$articleCountMethod
private

see $wgArticleCountMethod

Definition at line 161 of file DerivedPageDataUpdater.php.

Referenced by MediaWiki\Storage\DerivedPageDataUpdater\setArticleCountMethod().

◆ $contentHandlerFactory

IContentHandlerFactory MediaWiki\Storage\DerivedPageDataUpdater::$contentHandlerFactory
private
Initial value:
=[[,,,,],[,,,],[,,],[,,],]
private const TRANSITIONS
'new' =>
'new' => true
'knows-current' => true
'has-content' => true
'has-revision' => true
'knows-current' =>
'knows-current' => true
'has-content' => true
'has-revision' => true
'has-content' =>
'has-content' => true
'has-revision' => true
'has-revision' =>
'has-revision' => true
'done' => true

Definition at line 293 of file DerivedPageDataUpdater.php.

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

◆ $contentTransformer

ContentTransformer MediaWiki\Storage\DerivedPageDataUpdater::$contentTransformer
private

◆ $contLang

Language MediaWiki\Storage\DerivedPageDataUpdater::$contLang
private

◆ $editResultCache

EditResultCache MediaWiki\Storage\DerivedPageDataUpdater::$editResultCache
private

◆ $forceEmptyRevision

bool MediaWiki\Storage\DerivedPageDataUpdater::$forceEmptyRevision = false
private

Whether null-edits create a revision.

Definition at line 248 of file DerivedPageDataUpdater.php.

Referenced by MediaWiki\Storage\DerivedPageDataUpdater\setForceEmptyRevision().

◆ $hookRunner

HookRunner MediaWiki\Storage\DerivedPageDataUpdater::$hookRunner
private

Definition at line 151 of file DerivedPageDataUpdater.php.

◆ $jobQueueGroup

JobQueueGroup MediaWiki\Storage\DerivedPageDataUpdater::$jobQueueGroup
private

◆ $loadbalancerFactory

ILBFactory MediaWiki\Storage\DerivedPageDataUpdater::$loadbalancerFactory
private

◆ $logger

LoggerInterface MediaWiki\Storage\DerivedPageDataUpdater::$logger
private

◆ $mainWANObjectCache

WANObjectCache MediaWiki\Storage\DerivedPageDataUpdater::$mainWANObjectCache
private

◆ $messageCache

MessageCache MediaWiki\Storage\DerivedPageDataUpdater::$messageCache
private

◆ $options

MediaWiki\Storage\DerivedPageDataUpdater::$options
private
Initial value:
= [
'changed' => true,
'newrev' => false,
'created' => false,
'moved' => false,
'oldtitle' => null,
'restored' => false,
'oldrevision' => null,
'oldcountable' => null,
'oldredirect' => null,
'triggeringUser' => null,
'causeAction' => null,
'causeAgent' => null,
'editResult' => null,
'approved' => false,
]

Stores (most of) the $options parameter of prepareUpdate().

See also
prepareUpdate()

@phpcs:ignore Generic.Files.LineLength

Definition at line 175 of file DerivedPageDataUpdater.php.

◆ $pageEditStash

PageEditStash MediaWiki\Storage\DerivedPageDataUpdater::$pageEditStash
private

◆ $pageState

array MediaWiki\Storage\DerivedPageDataUpdater::$pageState = null
private

The state of the relevant row in page table before the edit.

This is determined by the first call to grabCurrentRevision, prepareContent, or prepareUpdate (so it is only accessible in 'knows-current' or a later stage). If pageState was not initialized when prepareUpdate() is called, prepareUpdate() will attempt to emulate the state of the page table before the edit.

Contains the following fields:

  • oldRevision (RevisionRecord|null): the revision that was current before the change associated with this update. Might not be set, use getParentRevision().
  • oldId (int|null): the id of the above revision. 0 if there is no such revision (the change was about creating a new page); null if not known (that should not happen).
  • oldIsRedirect (bool|null): whether the page was a redirect before the change. Lazy-loaded, can be null; use wasRedirect() instead of direct access.
  • oldCountable (bool|null): whether the page was countable before the change (or null if we don't have that information)

Definition at line 215 of file DerivedPageDataUpdater.php.

◆ $parentRevision

RevisionRecord null MediaWiki\Storage\DerivedPageDataUpdater::$parentRevision = null
private

Definition at line 225 of file DerivedPageDataUpdater.php.

◆ $parserCache

ParserCache MediaWiki\Storage\DerivedPageDataUpdater::$parserCache
private

◆ $permissionManager

PermissionManager MediaWiki\Storage\DerivedPageDataUpdater::$permissionManager
private

◆ $rcWatchCategoryMembership

bool MediaWiki\Storage\DerivedPageDataUpdater::$rcWatchCategoryMembership = false
private

see $wgRCWatchCategoryMembership

Definition at line 166 of file DerivedPageDataUpdater.php.

Referenced by MediaWiki\Storage\DerivedPageDataUpdater\setRcWatchCategoryMembership().

◆ $renderedRevision

RenderedRevision MediaWiki\Storage\DerivedPageDataUpdater::$renderedRevision = null
private

Definition at line 235 of file DerivedPageDataUpdater.php.

◆ $revision

RevisionRecord null MediaWiki\Storage\DerivedPageDataUpdater::$revision = null
private

◆ $revisionRenderer

RevisionRenderer MediaWiki\Storage\DerivedPageDataUpdater::$revisionRenderer
private

◆ $revisionStore

RevisionStore MediaWiki\Storage\DerivedPageDataUpdater::$revisionStore
private

◆ $slotRoleRegistry

SlotRoleRegistry MediaWiki\Storage\DerivedPageDataUpdater::$slotRoleRegistry
private

◆ $slotsUpdate

RevisionSlotsUpdate null MediaWiki\Storage\DerivedPageDataUpdater::$slotsUpdate = null
private

◆ $stage

string MediaWiki\Storage\DerivedPageDataUpdater::$stage = 'new'
private

A stage identifier for managing the life cycle of this instance.

Possible stages are 'new', 'knows-current', 'has-content', 'has-revision', and 'done'.

See also
docs/pageupdater.md for documentation of the life cycle.

Definition at line 258 of file DerivedPageDataUpdater.php.

Referenced by MediaWiki\Storage\DerivedPageDataUpdater\doTransition().

◆ $talkPageNotificationManager

TalkPageNotificationManager MediaWiki\Storage\DerivedPageDataUpdater::$talkPageNotificationManager
private

◆ $user

UserIdentity null MediaWiki\Storage\DerivedPageDataUpdater::$user = null
private

◆ $userNameUtils

UserNameUtils MediaWiki\Storage\DerivedPageDataUpdater::$userNameUtils
private

◆ $wikiPage

WikiPage MediaWiki\Storage\DerivedPageDataUpdater::$wikiPage
private

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