MediaWiki  master
MediaWiki\Storage\PageUpdater Class Reference

Controller-like object for creating and updating pages by creating new revisions. More...

Collaboration diagram for MediaWiki\Storage\PageUpdater:

Public Member Functions

 __construct (UserIdentity $author, WikiPage $wikiPage, DerivedPageDataUpdater $derivedDataUpdater, ILoadBalancer $loadBalancer, RevisionStore $revisionStore, SlotRoleRegistry $slotRoleRegistry, IContentHandlerFactory $contentHandlerFactory, HookContainer $hookContainer, UserEditTracker $userEditTracker, UserGroupManager $userGroupManager, TitleFormatter $titleFormatter, ServiceOptions $serviceOptions, array $softwareTags)
 
 addSoftwareTag (string $tag)
 Sets software tag to this update. More...
 
 addTag (string $tag)
 Sets a tag to apply to this update. More...
 
 addTags (array $tags)
 Sets tags to apply to this update. More...
 
 getEditResult ()
 Returns the EditResult associated with this PageUpdater. More...
 
 getExplicitTags ()
 Returns the list of tags set using the addTag() method. More...
 
 getNewRevision ()
 The new revision created by saveRevision(), or null if saveRevision() has not yet been called, failed, or did not create a new revision because the content did not change. More...
 
 getStatus ()
 The Status object indicating whether saveRevision() was successful, or null if saveRevision() was not yet called on this instance. More...
 
 grabParentRevision ()
 Returns the revision that was the page's current revision when grabParentRevision() was first called. More...
 
 hasEditConflict ( $expectedParentRevision)
 Checks whether this update conflicts with another update performed between the client loading data to prepare an edit, and the client committing the edit. More...
 
 inheritSlot (SlotRecord $originalSlot)
 Explicitly inherit a slot from some earlier revision. More...
 
 isNew ()
 Whether saveRevision() was called and created a new page. More...
 
 isUnchanged ()
 Whether saveRevision() did not create a revision because the content didn't change (null-edit). More...
 
 markAsRevert (int $revertMethod, int $newestRevertedRevId, int $revertAfterRevId=null)
 Marks this edit as a revert and applies relevant information. More...
 
 prepareUpdate (int $flags=0)
 Prepare the update. More...
 
 removeSlot ( $role)
 Removes the slot with the given role. More...
 
 saveRevision (CommentStoreComment $summary, int $flags=0)
 Change an existing article or create a new article. More...
 
 setContent ( $role, Content $content)
 Set the new content for the given slot role. More...
 
 setFlags (int $flags)
 Sets any flags to use when performing the update. More...
 
 setOriginalRevisionId ( $originalRevId)
 Sets the ID of an earlier revision that is being repeated or restored by this update. More...
 
 setRcPatrolStatus ( $status)
 Sets the "patrolled" status of the edit. More...
 
 setSlot (SlotRecord $slot)
 Set the new slot for the given slot role. More...
 
 setUseAutomaticEditSummaries ( $useAutomaticEditSummaries)
 Can be used to enable or disable automatic summaries that are applied to certain kinds of changes, like completely blanking a page. More...
 
 setUsePageCreationLog ( $use)
 Whether to create a log entry for new page creations. More...
 
 updateRevision (int $revId=0)
 Updates derived slots of an existing article. More...
 
 wasCommitted ()
 Whether saveRevision() has been called on this instance. More...
 
 wasSuccessful ()
 Whether saveRevision() completed successfully. More...
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 Options that have to be present in the ServiceOptions object passed to the constructor. More...
 

Private Member Functions

 buildEditResult (RevisionRecord $revision, bool $isNew)
 Builds the EditResult for this update. More...
 
 checkAllRequiredRoles (array $roles, Status $status)
 
 checkAllRolesAllowed (array $roles, Status $status)
 
 checkAllRolesDerived (array $roles, Status $status)
 
 checkNoRolesRequired (array $roles, Status $status)
 
 computeEffectiveTags ()
 
 doCreate (CommentStoreComment $summary)
 
 doModify (CommentStoreComment $summary)
 
 doUpdate (RevisionRecord $revision)
 Update derived slots in an existing revision. More...
 
 ensureRoleAllowed ( $role)
 
 ensureRoleNotRequired ( $role)
 
 getAllowedSlotRoles ()
 
 getAtomicSectionUpdate (IDatabase $dbw, WikiPage $wikiPage, RevisionRecord $newRevisionRecord, CommentStoreComment $summary, array $hints=[])
 
 getContentHandler ( $role)
 
 getDBConnectionRef ( $mode)
 
 getPage ()
 Get the page we're currently updating. More...
 
 getParentContent ( $role)
 Returns the content of the given slot of the parent revision, with no audience checks applied. More...
 
 getRequiredSlotRoles ()
 
 getTitle ()
 
 getWikiId ()
 
 getWikiPage ()
 
 makeAutoSummary ()
 
 makeNewRevision (CommentStoreComment $comment, Status $status)
 Constructs a MutableRevisionRecord based on the Content prepared by the DerivedPageDataUpdater. More...
 

Static Private Member Functions

static toLegacyUser (UserIdentity $user)
 

Private Attributes

UserIdentity $author
 
IContentHandlerFactory $contentHandlerFactory
 
DerivedPageDataUpdater $derivedDataUpdater
 
EditResult null $editResult = null
 
EditResultBuilder $editResultBuilder
 
int $flags = 0
 
HookContainer $hookContainer
 
HookRunner $hookRunner
 
ILoadBalancer $loadBalancer
 
int $rcPatrolStatus = RecentChange::PRC_UNPATROLLED
 the RC patrol status the new revision should be marked with. More...
 
RevisionStore $revisionStore
 
ServiceOptions $serviceOptions
 
SlotRoleRegistry $slotRoleRegistry
 
RevisionSlotsUpdate $slotsUpdate
 
string[] $softwareTags = []
 
Status null $status = null
 
array $tags = []
 
TitleFormatter $titleFormatter
 
bool $useAutomaticEditSummaries = true
 see $wgUseAutomaticEditSummaries More...
 
bool $usePageCreationLog = true
 whether to create a log entry for new page creations. More...
 
UserEditTracker $userEditTracker
 
UserGroupManager $userGroupManager
 
WikiPage $wikiPage
 

Detailed Description

Controller-like object for creating and updating pages by creating new revisions.

PageUpdater instances provide compare-and-swap (CAS) protection against concurrent updates between the time grabParentRevision() is called and saveRevision() inserts a new revision. This allows application logic to safely perform edit conflict resolution using the parent revision's content.

See also
docs/pageupdater.md for more information.

MCR migration note: this replaces the relevant methods in WikiPage.

Since
1.32

Definition at line 79 of file PageUpdater.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Storage\PageUpdater::__construct ( UserIdentity  $author,
WikiPage  $wikiPage,
DerivedPageDataUpdater  $derivedDataUpdater,
ILoadBalancer  $loadBalancer,
RevisionStore  $revisionStore,
SlotRoleRegistry  $slotRoleRegistry,
IContentHandlerFactory  $contentHandlerFactory,
HookContainer  $hookContainer,
UserEditTracker  $userEditTracker,
UserGroupManager  $userGroupManager,
TitleFormatter  $titleFormatter,
ServiceOptions  $serviceOptions,
array  $softwareTags 
)

Member Function Documentation

◆ addSoftwareTag()

MediaWiki\Storage\PageUpdater::addSoftwareTag ( string  $tag)

Sets software tag to this update.

If the tag is not defined in the current software tags, it's ignored.

Since
1.38
Parameters
string$tag
Returns
$this

Definition at line 627 of file PageUpdater.php.

References MediaWiki\Storage\PageUpdater\addTag().

◆ addTag()

MediaWiki\Storage\PageUpdater::addTag ( string  $tag)

Sets a tag to apply to this update.

Callers are responsible for permission checks, using ChangeTags::canAddTagsAccompanyingChange.

Parameters
string$tag
Returns
$this

Definition at line 599 of file PageUpdater.php.

Referenced by MediaWiki\Storage\PageUpdater\addSoftwareTag(), and MediaWiki\Storage\PageUpdater\addTags().

◆ addTags()

MediaWiki\Storage\PageUpdater::addTags ( array  $tags)

Sets tags to apply to this update.

Callers are responsible for permission checks, using ChangeTags::canAddTagsAccompanyingChange.

Parameters
string[]$tags
Returns
$this

Definition at line 611 of file PageUpdater.php.

References MediaWiki\Storage\PageUpdater\$tags, and MediaWiki\Storage\PageUpdater\addTag().

◆ buildEditResult()

MediaWiki\Storage\PageUpdater::buildEditResult ( RevisionRecord  $revision,
bool  $isNew 
)
private

Builds the EditResult for this update.

Should be called by either doModify or doCreate.

Parameters
RevisionRecord$revision
bool$isNew

Definition at line 1133 of file PageUpdater.php.

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

◆ checkAllRequiredRoles()

MediaWiki\Storage\PageUpdater::checkAllRequiredRoles ( array  $roles,
Status  $status 
)
private

◆ checkAllRolesAllowed()

MediaWiki\Storage\PageUpdater::checkAllRolesAllowed ( array  $roles,
Status  $status 
)
private

◆ checkAllRolesDerived()

MediaWiki\Storage\PageUpdater::checkAllRolesDerived ( array  $roles,
Status  $status 
)
private
Parameters
array$roles
Status$status

Definition at line 1577 of file PageUpdater.php.

References MediaWiki\Storage\PageUpdater\$status, and StatusValue\error().

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

◆ checkNoRolesRequired()

MediaWiki\Storage\PageUpdater::checkNoRolesRequired ( array  $roles,
Status  $status 
)
private

◆ computeEffectiveTags()

◆ doCreate()

◆ doModify()

◆ doUpdate()

MediaWiki\Storage\PageUpdater::doUpdate ( RevisionRecord  $revision)
private

◆ ensureRoleAllowed()

MediaWiki\Storage\PageUpdater::ensureRoleAllowed (   $role)
private

◆ ensureRoleNotRequired()

MediaWiki\Storage\PageUpdater::ensureRoleNotRequired (   $role)
private

◆ getAllowedSlotRoles()

MediaWiki\Storage\PageUpdater::getAllowedSlotRoles ( )
private
Returns
string[] Slots allowed for this page update, as a list of role names.

Definition at line 1538 of file PageUpdater.php.

References MediaWiki\Storage\PageUpdater\getPage().

Referenced by MediaWiki\Storage\PageUpdater\checkAllRolesAllowed(), and MediaWiki\Storage\PageUpdater\ensureRoleAllowed().

◆ getAtomicSectionUpdate()

◆ getContentHandler()

MediaWiki\Storage\PageUpdater::getContentHandler (   $role)
private

◆ getDBConnectionRef()

MediaWiki\Storage\PageUpdater::getDBConnectionRef (   $mode)
private
Parameters
int$modeDB_PRIMARY or DB_REPLICA
Returns
DBConnRef

Definition at line 377 of file PageUpdater.php.

References MediaWiki\Storage\PageUpdater\getWikiId().

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

◆ getEditResult()

MediaWiki\Storage\PageUpdater::getEditResult ( )

Returns the EditResult associated with this PageUpdater.

Will return null if PageUpdater::saveRevision() wasn't called yet. Will also return null if the update was not successful.

Returns
EditResult|null

Definition at line 588 of file PageUpdater.php.

References MediaWiki\Storage\PageUpdater\$editResult.

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

◆ getExplicitTags()

MediaWiki\Storage\PageUpdater::getExplicitTags ( )

Returns the list of tags set using the addTag() method.

Returns
string[]

Definition at line 639 of file PageUpdater.php.

References MediaWiki\Storage\PageUpdater\$tags.

◆ getNewRevision()

MediaWiki\Storage\PageUpdater::getNewRevision ( )

The new revision created by saveRevision(), or null if saveRevision() has not yet been called, failed, or did not create a new revision because the content did not change.

Returns
RevisionRecord|null

Definition at line 1039 of file PageUpdater.php.

◆ getPage()

◆ getParentContent()

MediaWiki\Storage\PageUpdater::getParentContent (   $role)
private

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

If there is no parent revision or the slot is not defined, this returns null.

Parameters
string$roleslot role name
Returns
Content|null

Definition at line 676 of file PageUpdater.php.

References MediaWiki\Storage\PageUpdater\grabParentRevision(), and MediaWiki\Revision\RevisionRecord\RAW.

Referenced by MediaWiki\Storage\PageUpdater\computeEffectiveTags(), and MediaWiki\Storage\PageUpdater\makeAutoSummary().

◆ getRequiredSlotRoles()

MediaWiki\Storage\PageUpdater::getRequiredSlotRoles ( )
private
Returns
string[] Slots required for this page update, as a list of role names.

Definition at line 1531 of file PageUpdater.php.

References MediaWiki\Storage\PageUpdater\getPage().

Referenced by MediaWiki\Storage\PageUpdater\checkAllRequiredRoles(), MediaWiki\Storage\PageUpdater\checkNoRolesRequired(), and MediaWiki\Storage\PageUpdater\ensureRoleNotRequired().

◆ getStatus()

MediaWiki\Storage\PageUpdater::getStatus ( )

The Status object indicating whether saveRevision() was successful, or null if saveRevision() was not yet called on this instance.

Note
This is here for compatibility with WikiPage::doEditContent. It may be deprecated soon.

Possible status errors: edit-hook-aborted: The ArticleSave hook aborted the update but didn't set the fatal flag of $status. edit-gone-missing: In update mode, but the article didn't exist. edit-conflict: In update mode, the article changed unexpectedly. edit-no-change: Warning that the text was the same as before. edit-already-exists: In creation mode, but the article already exists.

Extensions may define additional errors.

$return->value will contain an associative array with members as follows: new: Boolean indicating if the function attempted to create a new article. revision-record: The RevisionRecord object for the inserted revision, or null.

Returns
null|Status

Definition at line 998 of file PageUpdater.php.

References MediaWiki\Storage\PageUpdater\$status.

◆ getTitle()

MediaWiki\Storage\PageUpdater::getTitle ( )
private

◆ getWikiId()

MediaWiki\Storage\PageUpdater::getWikiId ( )
private

◆ getWikiPage()

◆ grabParentRevision()

MediaWiki\Storage\PageUpdater::grabParentRevision ( )

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

This revision is the expected parent revision of the update, and will be recorded as the new revision's parent revision (unless no new revision is created because the content was not changed).

This method MUST not be called after saveRevision() was called!

The current revision determined by the first call to this method effectively acts a compare-and-swap (CAS) token which is checked by saveRevision(), which fails if any concurrent updates created a new revision.

Application code should call this method before applying transformations to the new content that depend on the parent revision, e.g. adding/replacing sections, or resolving conflicts via a 3-way merge. This protects against race conditions triggered by concurrent updates.

See also
DerivedPageDataUpdater::grabCurrentRevision()
Note
The expected parent revision is not to be confused with the logical base revision. The base revision is specified by the client, the parent revision is determined from the database. If base revision and parent revision are not the same, the updates is considered to require edit conflict resolution.
Exceptions
LogicExceptionif called after saveRevision().
Returns
RevisionRecord|null the parent revision, or null of the page does not yet exist.

Definition at line 472 of file PageUpdater.php.

Referenced by MediaWiki\Storage\PageUpdater\doModify(), MediaWiki\Storage\PageUpdater\doUpdate(), MediaWiki\Storage\PageUpdater\getContentHandler(), MediaWiki\Storage\PageUpdater\getParentContent(), MediaWiki\Storage\PageUpdater\hasEditConflict(), MediaWiki\Storage\PageUpdater\makeNewRevision(), MediaWiki\Storage\PageUpdater\prepareUpdate(), and MediaWiki\Storage\PageUpdater\updateRevision().

◆ hasEditConflict()

MediaWiki\Storage\PageUpdater::hasEditConflict (   $expectedParentRevision)

Checks whether this update conflicts with another update performed between the client loading data to prepare an edit, and the client committing the edit.

This is intended to detect user level "edit conflict" when the latest revision known to the client is no longer the current revision when processing the update.

An update expected to create a new page can be checked by setting $expectedParentRevision = 0. Such an update is considered to have a conflict if a current revision exists (that is, the page was created since the edit was initiated on the client).

This method returning true indicates to calling code that edit conflict resolution should be applied before saving any data. It does not prevent the update from being performed, and it should not be confused with a "late" conflict indicated by the "edit-conflict" status. A "late" conflict is a CAS failure caused by an update being performed concurrently between the time grabParentRevision() was called and the time saveRevision() trying to insert the new revision.

Note
A user level edit conflict is not the same as the "edit-conflict" status triggered by a CAS failure. Calling this method establishes the CAS token, it does not check against it: This method calls grabParentRevision(), and thus causes the expected parent revision for the update to be fixed to the page's current revision at this point in time. It acts as a compare-and-swap (CAS) token in that it is guaranteed that saveRevision() will fail with the "edit-conflict" status if the current revision of the page changes after hasEditConflict() (or grabParentRevision()) was called and before saveRevision() could insert a new revision.
See also
grabParentRevision()
Parameters
int$expectedParentRevisionThe ID of the revision the client expects to be the current one. Use 0 to indicate that the page is expected to not yet exist.
Returns
bool

Definition at line 438 of file PageUpdater.php.

References MediaWiki\Storage\PageUpdater\grabParentRevision().

◆ inheritSlot()

MediaWiki\Storage\PageUpdater::inheritSlot ( SlotRecord  $originalSlot)

Explicitly inherit a slot from some earlier revision.

The primary use case for this is rollbacks, when slots are to be inherited from the rollback target, overriding the content from the parent revision (which is the revision being rolled back).

This should typically not be used to inherit slots from the parent revision, which happens implicitly. Using this method causes the given slot to be treated as "modified" during revision creation, even if it has the same content as in the parent revision.

Parameters
SlotRecord$originalSlotA slot already existing in the database, to be inherited by the new revision.
Returns
$this

Definition at line 518 of file PageUpdater.php.

References MediaWiki\Revision\SlotRecord\newInherited().

◆ isNew()

MediaWiki\Storage\PageUpdater::isNew ( )

Whether saveRevision() was called and created a new page.

Returns
bool

Definition at line 1016 of file PageUpdater.php.

◆ isUnchanged()

MediaWiki\Storage\PageUpdater::isUnchanged ( )

Whether saveRevision() did not create a revision because the content didn't change (null-edit).

Whether the content changed or not is determined by DerivedPageDataUpdater::isChange().

Returns
bool

Definition at line 1027 of file PageUpdater.php.

◆ makeAutoSummary()

◆ makeNewRevision()

MediaWiki\Storage\PageUpdater::makeNewRevision ( CommentStoreComment  $comment,
Status  $status 
)
private

Constructs a MutableRevisionRecord based on the Content prepared by the DerivedPageDataUpdater.

This takes care of inheriting slots, updating slots with PST applied, and removing discontinued slots.

This calls Content::prepareSave() to verify that the slot content can be saved. The $status parameter is updated with any errors or warnings found by Content::prepareSave().

Parameters
CommentStoreComment$comment
Status$status
Returns
MutableRevisionRecord

Definition at line 1058 of file PageUpdater.php.

References $content, MediaWiki\Storage\PageUpdater\$status, $title, MediaWiki\Storage\PageUpdater\$wikiPage, MediaWiki\Storage\PageUpdater\checkAllRequiredRoles(), EDIT_MINOR, MediaWiki\Storage\PageUpdater\getTitle(), MediaWiki\Storage\PageUpdater\getWikiPage(), MediaWiki\Storage\PageUpdater\grabParentRevision(), StatusValue\merge(), MediaWiki\Storage\PageUpdater\toLegacyUser(), and wfWarn().

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

◆ markAsRevert()

MediaWiki\Storage\PageUpdater::markAsRevert ( int  $revertMethod,
int  $newestRevertedRevId,
int  $revertAfterRevId = null 
)

Marks this edit as a revert and applies relevant information.

Will also cause the PageUpdater to add a relevant change tag when saving the edit.

Parameters
int$revertMethodThe method used to make the revert: REVERT_UNDO, REVERT_ROLLBACK or REVERT_MANUAL
int$newestRevertedRevIdthe revision ID of the latest reverted revision.
int | null$revertAfterRevIdthe revision ID after which revisions are being reverted. Defaults to the revision before the $newestRevertedRevId.
Returns
$this
See also
EditResultBuilder::markAsRevert()

Definition at line 570 of file PageUpdater.php.

◆ prepareUpdate()

MediaWiki\Storage\PageUpdater::prepareUpdate ( int  $flags = 0)

Prepare the update.

This sets up the RevisionRecord to be saved.

Since
1.37
Parameters
int$flagsBitfield, will be combined with flags set via setFlags(). EDIT_FORCE_BOT and EDIT_INTERNAL will bypass the edit stash.

Definition at line 301 of file PageUpdater.php.

References EDIT_FORCE_BOT, EDIT_INTERNAL, MediaWiki\Storage\PageUpdater\grabParentRevision(), and MediaWiki\Storage\PageUpdater\setFlags().

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

◆ removeSlot()

MediaWiki\Storage\PageUpdater::removeSlot (   $role)

Removes the slot with the given role.

This discontinues the "stream" of slots with this role on the page, preventing the new revision, and any subsequent revisions, from inheriting the slot with this role.

Parameters
string$roleA slot role name (but not "main")

Definition at line 537 of file PageUpdater.php.

References MediaWiki\Storage\PageUpdater\ensureRoleNotRequired().

◆ saveRevision()

MediaWiki\Storage\PageUpdater::saveRevision ( CommentStoreComment  $summary,
int  $flags = 0 
)

Change an existing article or create a new article.

Updates RC and all necessary caches, optionally via the deferred update array. This does not check user permissions.

It is guaranteed that saveRevision() will fail if the current revision of the page changes after grabParentRevision() was called and before saveRevision() can insert a new revision, as per the CAS mechanism described above.

The caller is however responsible for calling hasEditConflict() to detect a user-level edit conflict, and to adjust the content of the new revision accordingly, e.g. by using a 3-way-merge.

MCR migration note: this replaces WikiPage::doEditContent. Callers that change to using saveRevision() now need to check the "minoredit" themselves before using EDIT_MINOR.

Parameters
CommentStoreComment$summaryEdit summary
int$flagsBitfield, will be combined with the flags set via setFlags(). See there for details.
Note
If neither EDIT_NEW nor EDIT_UPDATE is specified, the expected state is detected automatically via grabParentRevision(). In this case, the "edit-already-exists" or "edit-gone-missing" errors may still be triggered due to race conditions, if the page was unexpectedly created or deleted while revision creation is in progress. This can be viewed as part of the CAS mechanism described above.
Returns
RevisionRecord|null The new revision, or null if no new revision was created due to a failure or a null-edit. Use isUnchanged(), wasSuccessful() and getStatus() to determine the outcome of the revision creation.
Exceptions
MWException
RuntimeException

Definition at line 767 of file PageUpdater.php.

References MediaWiki\Storage\PageUpdater\$status, DeferredUpdates\addCallableUpdate(), MediaWiki\Storage\PageUpdater\checkAllRolesAllowed(), MediaWiki\Storage\PageUpdater\checkNoRolesRequired(), MediaWiki\Storage\PageUpdater\doCreate(), MediaWiki\Storage\PageUpdater\doModify(), EDIT_MINOR, EDIT_NEW, EDIT_UPDATE, ContentHandler\getLocalizedName(), MediaWiki\Storage\PageUpdater\getPage(), MediaWiki\Storage\PageUpdater\getWikiPage(), StatusValue\isOK(), MediaWiki\Revision\SlotRecord\MAIN, MediaWiki\Storage\PageUpdater\makeAutoSummary(), StatusValue\newFatal(), StatusValue\newGood(), MediaWiki\Storage\PageUpdater\prepareUpdate(), MediaWiki\Storage\PageUpdater\setFlags(), MediaWiki\Storage\PageUpdater\toLegacyUser(), MediaWiki\Storage\PageUpdater\wasCommitted(), and wfMessage().

◆ setContent()

MediaWiki\Storage\PageUpdater::setContent (   $role,
Content  $content 
)

Set the new content for the given slot role.

Parameters
string$roleA slot role name (such as "main")
Content$content
Returns
$this

Definition at line 483 of file PageUpdater.php.

References $content, and MediaWiki\Storage\PageUpdater\ensureRoleAllowed().

◆ setFlags()

MediaWiki\Storage\PageUpdater::setFlags ( int  $flags)

Sets any flags to use when performing the update.

Flags passed in subsequent calls to this method as well as calls to prepareUpdate() or saveRevision() are aggregated using bitwise OR.

Known flags:

 EDIT_NEW
     Create a new page, or fail with "edit-already-exists" if the page exists.
 EDIT_UPDATE
     Create a new revision, or fail with "edit-gone-missing" if the page does not exist.
 EDIT_MINOR
     Mark this revision as minor
 EDIT_SUPPRESS_RC
     Do not log the change in recentchanges
 EDIT_FORCE_BOT
     Mark the revision as automated ("bot edit")
 EDIT_AUTOSUMMARY
     Fill in blank summaries with generated text where possible
 EDIT_INTERNAL
     Signal that the page retrieve/save cycle happened entirely in this request.
Parameters
int$flagsBitfield
Returns
$this

Definition at line 287 of file PageUpdater.php.

References MediaWiki\Storage\PageUpdater\$flags.

Referenced by MediaWiki\Storage\PageUpdater\prepareUpdate(), and MediaWiki\Storage\PageUpdater\saveRevision().

◆ setOriginalRevisionId()

MediaWiki\Storage\PageUpdater::setOriginalRevisionId (   $originalRevId)

Sets the ID of an earlier revision that is being repeated or restored by this update.

The new revision is expected to have the exact same content as the given original revision. This is used with rollbacks and with dummy "null" revisions which are created to record things like page moves.

Parameters
int | bool$originalRevIdThe original revision id, or false if no earlier revision is known to be repeated or restored by this update.
Returns
$this

Definition at line 553 of file PageUpdater.php.

◆ setRcPatrolStatus()

MediaWiki\Storage\PageUpdater::setRcPatrolStatus (   $status)

Sets the "patrolled" status of the edit.

Callers should check the "patrol" and "autopatrol" permissions as appropriate.

See also
$wgUseRCPatrol
$wgUseNPPatrol
Parameters
int$statusRC patrol status, e.g. RecentChange::PRC_AUTOPATROLLED.
Returns
$this

Definition at line 350 of file PageUpdater.php.

References MediaWiki\Storage\PageUpdater\$status.

◆ setSlot()

MediaWiki\Storage\PageUpdater::setSlot ( SlotRecord  $slot)

Set the new slot for the given slot role.

Parameters
SlotRecord$slot
Returns
$this

Definition at line 496 of file PageUpdater.php.

References MediaWiki\Storage\PageUpdater\ensureRoleAllowed(), and MediaWiki\Revision\SlotRecord\getRole().

◆ setUseAutomaticEditSummaries()

MediaWiki\Storage\PageUpdater::setUseAutomaticEditSummaries (   $useAutomaticEditSummaries)

Can be used to enable or disable automatic summaries that are applied to certain kinds of changes, like completely blanking a page.

Parameters
bool$useAutomaticEditSummaries
Returns
$this
See also
$wgUseAutomaticEditSummaries

Definition at line 335 of file PageUpdater.php.

References MediaWiki\Storage\PageUpdater\$useAutomaticEditSummaries.

◆ setUsePageCreationLog()

MediaWiki\Storage\PageUpdater::setUsePageCreationLog (   $use)

Whether to create a log entry for new page creations.

See also
$wgPageCreationLog
Parameters
bool$use
Returns
$this

Definition at line 363 of file PageUpdater.php.

◆ toLegacyUser()

static MediaWiki\Storage\PageUpdater::toLegacyUser ( UserIdentity  $user)
staticprivate
Parameters
UserIdentity$user
Returns
User

Definition at line 323 of file PageUpdater.php.

References User\newFromIdentity().

Referenced by MediaWiki\Storage\PageUpdater\makeNewRevision(), and MediaWiki\Storage\PageUpdater\saveRevision().

◆ updateRevision()

MediaWiki\Storage\PageUpdater::updateRevision ( int  $revId = 0)

Updates derived slots of an existing article.

Does not update RC. Updates all necessary caches, optionally via the deferred update array. This does not check user permissions. Does not do a PST.

Use isUnchanged(), wasSuccessful() and getStatus() to determine the outcome of the revision update.

Parameters
int$revId
Since
1.36

Definition at line 901 of file PageUpdater.php.

References MediaWiki\Storage\PageUpdater\$status, MediaWiki\Storage\PageUpdater\checkAllRolesAllowed(), MediaWiki\Storage\PageUpdater\checkAllRolesDerived(), MediaWiki\Storage\PageUpdater\doUpdate(), EDIT_INTERNAL, StatusValue\fatal(), ContentHandler\getLocalizedName(), MediaWiki\Storage\PageUpdater\getPage(), MediaWiki\Storage\PageUpdater\grabParentRevision(), StatusValue\isOK(), StatusValue\newFatal(), StatusValue\newGood(), MediaWiki\Storage\PageUpdater\wasCommitted(), and wfMessage().

◆ wasCommitted()

MediaWiki\Storage\PageUpdater::wasCommitted ( )

Whether saveRevision() has been called on this instance.

Returns
bool

Definition at line 971 of file PageUpdater.php.

Referenced by MediaWiki\Storage\PageUpdater\saveRevision(), and MediaWiki\Storage\PageUpdater\updateRevision().

◆ wasSuccessful()

MediaWiki\Storage\PageUpdater::wasSuccessful ( )

Whether saveRevision() completed successfully.

Returns
bool

Definition at line 1007 of file PageUpdater.php.

Member Data Documentation

◆ $author

UserIdentity MediaWiki\Storage\PageUpdater::$author
private

Definition at line 94 of file PageUpdater.php.

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

◆ $contentHandlerFactory

IContentHandlerFactory MediaWiki\Storage\PageUpdater::$contentHandlerFactory
private

Definition at line 124 of file PageUpdater.php.

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

◆ $derivedDataUpdater

DerivedPageDataUpdater MediaWiki\Storage\PageUpdater::$derivedDataUpdater
private

Definition at line 104 of file PageUpdater.php.

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

◆ $editResult

◆ $editResultBuilder

EditResultBuilder MediaWiki\Storage\PageUpdater::$editResultBuilder
private

Definition at line 179 of file PageUpdater.php.

◆ $flags

int MediaWiki\Storage\PageUpdater::$flags = 0
private

Definition at line 194 of file PageUpdater.php.

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

◆ $hookContainer

HookContainer MediaWiki\Storage\PageUpdater::$hookContainer
private

Definition at line 134 of file PageUpdater.php.

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

◆ $hookRunner

HookRunner MediaWiki\Storage\PageUpdater::$hookRunner
private

Definition at line 129 of file PageUpdater.php.

◆ $loadBalancer

ILoadBalancer MediaWiki\Storage\PageUpdater::$loadBalancer
private

Definition at line 109 of file PageUpdater.php.

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

◆ $rcPatrolStatus

int MediaWiki\Storage\PageUpdater::$rcPatrolStatus = RecentChange::PRC_UNPATROLLED
private

the RC patrol status the new revision should be marked with.

Definition at line 154 of file PageUpdater.php.

◆ $revisionStore

RevisionStore MediaWiki\Storage\PageUpdater::$revisionStore
private

Definition at line 114 of file PageUpdater.php.

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

◆ $serviceOptions

ServiceOptions MediaWiki\Storage\PageUpdater::$serviceOptions
private

Definition at line 189 of file PageUpdater.php.

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

◆ $slotRoleRegistry

SlotRoleRegistry MediaWiki\Storage\PageUpdater::$slotRoleRegistry
private

Definition at line 119 of file PageUpdater.php.

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

◆ $slotsUpdate

RevisionSlotsUpdate MediaWiki\Storage\PageUpdater::$slotsUpdate
private

Definition at line 169 of file PageUpdater.php.

◆ $softwareTags

string [] MediaWiki\Storage\PageUpdater::$softwareTags = []
private

Definition at line 197 of file PageUpdater.php.

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

◆ $status

◆ $tags

◆ $titleFormatter

TitleFormatter MediaWiki\Storage\PageUpdater::$titleFormatter
private

Definition at line 143 of file PageUpdater.php.

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

◆ $useAutomaticEditSummaries

bool MediaWiki\Storage\PageUpdater::$useAutomaticEditSummaries = true
private

see $wgUseAutomaticEditSummaries

See also
$wgUseAutomaticEditSummaries

Definition at line 149 of file PageUpdater.php.

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

◆ $usePageCreationLog

bool MediaWiki\Storage\PageUpdater::$usePageCreationLog = true
private

whether to create a log entry for new page creations.

Definition at line 159 of file PageUpdater.php.

◆ $userEditTracker

UserEditTracker MediaWiki\Storage\PageUpdater::$userEditTracker
private

Definition at line 137 of file PageUpdater.php.

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

◆ $userGroupManager

UserGroupManager MediaWiki\Storage\PageUpdater::$userGroupManager
private

Definition at line 140 of file PageUpdater.php.

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

◆ $wikiPage

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\Storage\PageUpdater::CONSTRUCTOR_OPTIONS
Initial value:
= [
'ManualRevertSearchRadius',
'UseRCPatrol',
]

Options that have to be present in the ServiceOptions object passed to the constructor.

Note
When adding options here, also add them to PageUpdaterFactory::CONSTRUCTOR_OPTIONS.
Access: internal

Definition at line 86 of file PageUpdater.php.

Referenced by MediaWiki\Storage\PageUpdaterFactory\newPageUpdaterForDerivedPageDataUpdater().


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