|
MediaWiki master
|
A handle for managing updates for derived page data on edit, import, purge, etc. More...
Inherits LoggerAwareInterface, and MediaWiki\Storage\PreparedUpdate.

Public Member Functions | |
| __construct (private readonly ServiceOptions $serviceOptions, PageIdentity $page, private readonly RevisionStore $revisionStore, private readonly RevisionRenderer $revisionRenderer, private readonly SlotRoleRegistry $slotRoleRegistry, private readonly ParserCache $parserCache, private readonly JobQueueGroup $jobQueueGroup, private readonly Language $contLang, private readonly ILBFactory $loadbalancerFactory, private readonly IContentHandlerFactory $contentHandlerFactory, HookContainer $hookContainer, private readonly DomainEventDispatcher $eventDispatcher, private readonly EditResultCache $editResultCache, private readonly ContentTransformer $contentTransformer, private readonly PageEditStash $pageEditStash, private readonly WANObjectCache $mainWANObjectCache, WikiPageFactory $wikiPageFactory, private readonly ChangeTagsStore $changeTagsStore,) | |
| doParserCacheUpdate () | |
| Causes parser cache entries to be updated. | |
| doSecondaryDataUpdates (array $options=[]) | |
| Do secondary data updates (e.g. | |
| doUpdates () | |
| Do standard updates after page edit, purge, or import. | |
| emitEvents () | |
| getCanonicalParserOptions () | |
| getCanonicalParserOutput () | |
Returns the canonical parser output.Code that does not need access to the rendered HTML should use getParserOutputForMetaData() instead.
| |
| getModifiedSlotRoles () | |
| Returns the role names of the slots modified by the new revision, not including removed roles. | |
| getPage () | |
| Returns the page being updated. | |
| getParserOutputForMetaData () | |
| getPreparedEdit () | |
| getRawContent (string $role) | |
| Returns the content of the given slot, with no audience checks. | |
| getRawSlot ( $role) | |
| Returns the slot, modified or inherited, after PST, with no audience checks applied. | |
| getRemovedSlotRoles () | |
| Returns the role names of the slots removed by the new revision. | |
| getRenderedRevision () | |
| Returns a RenderedRevision instance acting as a lazy holder for the ParserOutput of the revision. | |
| getRevision () | |
| Returns the update's target revision - that is, the revision that will be the current revision after the update. | |
| getSecondaryDataUpdates ( $recursive=false) | |
| getSlotParserOutput ( $role, $generateHtml=true) | |
| getSlots () | |
| Returns the slots of the target revision, after PST. | |
| getTouchedSlotRoles () | |
| Returns the role names of the slots touched by the new revision, including removed roles. | |
| grabCurrentRevision () | |
| grabLatestRevision () | |
| Returns the revision that was the page's latest revision when grabLatestRevision() was first called. | |
| isChange () | |
| Whether the content of the latest revision after the edit is different from the content of the latest revision before the edit. | |
| isContentDeleted () | |
| Whether the content is deleted and thus not visible to the public. | |
| isContentPrepared () | |
| Whether prepareUpdate() or prepareContent() have been called on this instance. | |
| isCountable () | |
| Whether the page will be countable after the edit. | |
| isCreation () | |
| Whether the edit creates the page. | |
| isRedirect () | |
| Whether the page will be a redirect after the edit. | |
| 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. | |
| isUpdatePrepared () | |
| Whether prepareUpdate() has been called on this instance. | |
| pageExisted () | |
| Determines whether the page being edited already existed. | |
| prepareContent (UserIdentity $user, RevisionSlotsUpdate $slotsUpdate, $useStash=true) | |
| Prepare updates based on an update which has not yet been saved. | |
| prepareUpdate (RevisionRecord $revision, array $options=[]) | |
| Prepare derived data updates targeting the given RevisionRecord. | |
| setCause (string $cause) | |
| Set the cause of the update. | |
| setForceEmptyRevision (bool $forceEmptyRevision) | |
| Set whether null-edits should create a revision. | |
| setLogger (LoggerInterface $logger) | |
| setPerformer (UserIdentity $performer) | |
| Set the performer of the action. | |
| wasRedirect () | |
| Whether the page was a redirect before the edit. | |
Public Attributes | |
| const array | CONSTRUCTOR_OPTIONS |
A handle for managing updates for derived page data on edit, import, purge, etc.
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: grabLatestRevision (optional), prepareContent (optional), prepareUpdate (required for doUpdates). getCanonicalParserOutput, getSlots, and getSecondaryDataUpdates require prepareContent or prepareUpdate to have been called first, to initialize the DerivedPageDataUpdater.
MCR migration note: this replaces the relevant methods in WikiPage, and covers the use cases of PreparedEdit.
Definition at line 91 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::__construct | ( | private readonly ServiceOptions | $serviceOptions, |
| PageIdentity | $page, | ||
| private readonly RevisionStore | $revisionStore, | ||
| private readonly RevisionRenderer | $revisionRenderer, | ||
| private readonly SlotRoleRegistry | $slotRoleRegistry, | ||
| private readonly ParserCache | $parserCache, | ||
| private readonly JobQueueGroup | $jobQueueGroup, | ||
| private readonly Language | $contLang, | ||
| private readonly ILBFactory | $loadbalancerFactory, | ||
| private readonly IContentHandlerFactory | $contentHandlerFactory, | ||
| HookContainer | $hookContainer, | ||
| private readonly DomainEventDispatcher | $eventDispatcher, | ||
| private readonly EditResultCache | $editResultCache, | ||
| private readonly ContentTransformer | $contentTransformer, | ||
| private readonly PageEditStash | $pageEditStash, | ||
| private readonly WANObjectCache | $mainWANObjectCache, | ||
| WikiPageFactory | $wikiPageFactory, | ||
| private readonly ChangeTagsStore | $changeTagsStore ) |
Definition at line 205 of file DerivedPageDataUpdater.php.
References MediaWiki\Page\WikiPageFactory\newFromTitle().
| MediaWiki\Storage\DerivedPageDataUpdater::doParserCacheUpdate | ( | ) |
Causes parser cache entries to be updated.
Definition at line 1773 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::doSecondaryDataUpdates | ( | array | $options = [] | ) |
Do secondary data updates (e.g.
updating link tables) or schedule them as deferred updates
| array | $options |
|
Definition at line 1731 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::doUpdates | ( | ) |
Do standard updates after page edit, purge, or import.
Update links tables and other derived data. Purges pages that depend on this page when appropriate. With a 10% chance, triggers pruning the recent changes table.
Further updates may be triggered by core components and extensions that listen to the PageLatestRevisionChanged event. Search for method names starting with "handlePageLatestRevisionChangedEvent" to find listeners.
MCR migration note: this replaces WikiPage::doEditUpdates.
Definition at line 1422 of file DerivedPageDataUpdater.php.
References MediaWiki\Revision\RevisionRecord\getId(), and wfDebug().
| MediaWiki\Storage\DerivedPageDataUpdater::emitEvents | ( | ) |
Definition at line 1541 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::getCanonicalParserOptions | ( | ) |
Definition at line 1300 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::getCanonicalParserOutput | ( | ) |
Returns the canonical parser output.Code that does not need access to the rendered HTML should use getParserOutputForMetaData() instead.
Implements MediaWiki\Storage\PreparedUpdate.
Definition at line 1296 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::getModifiedSlotRoles | ( | ) |
Returns the role names of the slots modified by the new revision, not including removed roles.
Implements MediaWiki\Storage\PreparedUpdate.
Definition at line 1005 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::getPage | ( | ) |
Returns the page being updated.
Implements MediaWiki\Storage\PreparedUpdate.
Definition at line 417 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::getParserOutputForMetaData | ( | ) |
Implements MediaWiki\Storage\PreparedUpdate.
Definition at line 1288 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::getPreparedEdit | ( | ) |
Definition at line 1252 of file DerivedPageDataUpdater.php.
References MediaWiki\Storage\RevisionSlotsUpdate\getModifiedSlot(), and MediaWiki\Storage\RevisionSlotsUpdate\isModifiedSlot().
| MediaWiki\Storage\DerivedPageDataUpdater::getRawContent | ( | string | $role | ) |
Returns the content of the given slot, with no audience checks.
| PageUpdateException | If the slot is neither set for update nor inherited from the parent revision. |
| string | $role | slot role name |
Implements MediaWiki\Storage\PreparedUpdate.
Definition at line 597 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::getRawSlot | ( | $role | ) |
Returns the slot, modified or inherited, after PST, with no audience checks applied.
| string | $role | slot role name |
| PageUpdateException | If the slot is neither set for update nor inherited from the parent revision. |
Definition at line 585 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::getRemovedSlotRoles | ( | ) |
Returns the role names of the slots removed by the new revision.
Implements MediaWiki\Storage\PreparedUpdate.
Definition at line 1014 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::getRenderedRevision | ( | ) |
Returns a RenderedRevision instance acting as a lazy holder for the ParserOutput of the revision.
Implements MediaWiki\Storage\PreparedUpdate.
Definition at line 879 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::getRevision | ( | ) |
Returns the update's target revision - that is, the revision that will be the current revision after the update.
Implements MediaWiki\Storage\PreparedUpdate.
Definition at line 874 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::getSecondaryDataUpdates | ( | $recursive = false | ) |
| bool | $recursive |
Definition at line 1309 of file DerivedPageDataUpdater.php.
References MediaWiki\Revision\RevisionRecord\getSlot().
| MediaWiki\Storage\DerivedPageDataUpdater::getSlotParserOutput | ( | $role, | |
| $generateHtml = true ) |
| string | $role | |
| bool | $generateHtml |
Definition at line 1277 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::getSlots | ( | ) |
Returns the slots of the target revision, after PST.
Definition at line 966 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::getTouchedSlotRoles | ( | ) |
Returns the role names of the slots touched by the new revision, including removed roles.
Definition at line 995 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::grabCurrentRevision | ( | ) |
Definition at line 530 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::grabLatestRevision | ( | ) |
Returns the revision that was the page's latest revision when grabLatestRevision() 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.
Definition at line 498 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::isChange | ( | ) |
Whether the content of the latest revision after the edit is different from the content of the latest revision before the edit.
This will return false for a null-edit (no revision created), as well as for a dummy revision (a revision with the same content as its parent).
Definition at line 932 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::isContentDeleted | ( | ) |
Whether the content is deleted and thus not visible to the public.
Definition at line 567 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::isContentPrepared | ( | ) |
Whether prepareUpdate() or prepareContent() have been called on this instance.
Definition at line 539 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::isCountable | ( | ) |
Whether the page will be countable after the edit.
Implements MediaWiki\Storage\PreparedUpdate.
Definition at line 606 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::isCreation | ( | ) |
Whether the edit creates the page.
Definition at line 915 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::isRedirect | ( | ) |
Whether the page will be a redirect after the edit.
Implements MediaWiki\Storage\PreparedUpdate.
Definition at line 648 of file DerivedPageDataUpdater.php.
| 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.
| UserIdentity | null | $user | The user creating the revision in question |
| RevisionRecord | null | $revision | New revision (after save, if already saved) |
| RevisionSlotsUpdate | null | $slotsUpdate | New content (before PST) |
| null | int | $parentId | Parent revision of the edit (use 0 for page creation) |
Definition at line 318 of file DerivedPageDataUpdater.php.
References MediaWiki\Revision\RevisionRecord\getId(), MediaWiki\User\UserIdentity\getName(), MediaWiki\Revision\RevisionRecord\getParentId(), MediaWiki\Revision\RevisionRecord\getSlots(), and MediaWiki\Storage\RevisionSlotsUpdate\hasSameUpdates().
| MediaWiki\Storage\DerivedPageDataUpdater::isUpdatePrepared | ( | ) |
Whether prepareUpdate() has been called on this instance.
Definition at line 550 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::pageExisted | ( | ) |
Determines whether the page being edited already existed.
Only defined after calling grabLatestRevision() or prepareContent() or prepareUpdate()!
| LogicException | if called before grabLatestRevision() |
Definition at line 428 of file DerivedPageDataUpdater.php.
| 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.
| UserIdentity | $user | The user to act as context for pre-save transformation (PST). |
| RevisionSlotsUpdate | $slotsUpdate | The new content of the slots to be updated by this edit, before PST. |
| bool | $useStash | Whether to use stashed ParserOutput |
Definition at line 691 of file DerivedPageDataUpdater.php.
References MediaWiki\Title\Title\equals(), MediaWiki\Revision\RevisionRecord\getComment(), MediaWiki\Revision\RevisionRecord\getId(), MediaWiki\Storage\RevisionSlotsUpdate\getModifiedRoles(), MediaWiki\Storage\RevisionSlotsUpdate\getModifiedSlot(), MediaWiki\User\UserIdentity\getName(), MediaWiki\Revision\RevisionRecord\getPageId(), MediaWiki\Revision\RevisionRecord\getParentId(), MediaWiki\Storage\RevisionSlotsUpdate\getRemovedRoles(), MediaWiki\Revision\RevisionRecord\getSlot(), MediaWiki\Revision\RevisionRecord\getSlotRoles(), MediaWiki\Revision\RevisionRecord\getSlots(), MediaWiki\Revision\RevisionRecord\getTimestamp(), MediaWiki\Revision\RevisionRecord\getUser(), MediaWiki\Revision\RevisionRecord\getVisibility(), MediaWiki\Revision\RevisionRecord\hasSameContent(), MediaWiki\Revision\RevisionRecord\isMinor(), and MediaWiki\Storage\RevisionSlotsUpdate\isModifiedSlot().
| 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.
| RevisionRecord | $revision | |
| array | $options | Array of options. Supports the flags defined by PageLatestRevisionChangedEvent. In addition, the following keys are supported used:
|
Definition at line 1063 of file DerivedPageDataUpdater.php.
References MediaWiki\Revision\RevisionRecord\getId(), MediaWiki\User\UserIdentity\getName(), MediaWiki\Revision\RevisionRecord\getParentId(), MediaWiki\Revision\RevisionRecord\getSlots(), and MediaWiki\Revision\RevisionRecord\getUser().
| MediaWiki\Storage\DerivedPageDataUpdater::setCause | ( | string | $cause | ) |
Set the cause of the update.
Will be used for the PageLatestRevisionChangedEvent and for tracing/logging in jobs, etc.
| string | $cause | See PageLatestRevisionChangedEvent::CAUSE_XXX |
Definition at line 247 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::setForceEmptyRevision | ( | bool | $forceEmptyRevision | ) |
Set whether null-edits should create a revision.
Enabling this allows the creation of dummy revisions (aka null revisions) to mark events such as renaming in the page history.
Must not be called once prepareContent() or prepareUpdate() have been called.
| bool | $forceEmptyRevision |
Definition at line 388 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::setLogger | ( | LoggerInterface | $logger | ) |
Definition at line 235 of file DerivedPageDataUpdater.php.
| MediaWiki\Storage\DerivedPageDataUpdater::setPerformer | ( | UserIdentity | $performer | ) |
Set the performer of the action.
Definition at line 261 of file DerivedPageDataUpdater.php.
References MediaWiki\User\UserIdentity\getName().
| MediaWiki\Storage\DerivedPageDataUpdater::wasRedirect | ( | ) |
Whether the page was a redirect before the edit.
Definition at line 942 of file DerivedPageDataUpdater.php.
| const array MediaWiki\Storage\DerivedPageDataUpdater::CONSTRUCTOR_OPTIONS |
Definition at line 93 of file DerivedPageDataUpdater.php.