Jump to content


From mediawiki.org

An instance of the PageUpdater class serves as a controller-like object for creating and updating pages by creating a new revision, or null revision, of a page. Features included:

  • It allows for edit conflict resolution by offering compare-and-swap (CAS) protection against concurrent updates that occur between the time grabParentRevision() is called and saveRevision() inserts a new revision.
  • It allows for the creation and update of content slots other than the main one.
  • It allows for updates to be associated with edit tags and other information.

The PageUpdater class can be instantiated with WikiPage::newPageUpdater() (don't use the PageUpdaterFactory class).

Public methods[edit]

  • saveRevision() - either change an existing article or create a new one.
  • grabParentRevision() - return the 'parent revision', i.e. the currently known page revision to serve as the parent of the revision or update so that compare-and-swap (CAS) operations can be run. Must be called after saveRevision().
  • updateRevision() - update derived slots of an existing article, along with caches (but not RC).
  • getNewRevision() - get the new revision created by saveRevision()
  • preventChange() - prevents the creation of new revision.
  • Checks, etc., related to saveRevision()
    • wasCommitted() - check whether saveRevision() has been called on this instance.
    • getStatus()
    • wasSuccessful() - check if saveRevision() was successful.
    • wasRevisionCreated() - check if saveRevision() created a revision.
    • isUnchanged() - deprecated since 1.38 in favour of wasRevisionCreated()
    • isNew() - check if saveRevision() was called and created a new page.
    • isChange() - check if the prepared edit is a change compared to the previous revision.
  • setFlags() - set flags to use when performing the update (EDIT_NEW, EDIT_UPDATE, EDIT_MINOR, etc.).
  • prepareUpdate() - set up the RevisionRecord to be saved.
  • updateAuthor() - update UserIdentity after creating the user (since 1.39)
  • setUseAutomaticEditSummaries() - enable/disable edit summaries to changes
  • setRcPatrolStatus() - set the 'patrolled' status of the edit.
  • setUsePageCreationLog() - whether or not to create a log entry when a page is created.
  • setForceEmptyRevision() - whether or not to create a null revision, i.e. whether null edits should create a revision.
  • getPage() - get the page (PageIdentity) currently being updated.
  • hasEditConflict() - check whether or not the current update creates an edit conflict.
  • Methods relating to content slots:
    • setContent() - set the new content for a given slot role.
    • setSlot() - set the new slot for a given slot role.
    • inheritSlot() - explicitly inherit a slot from some earlier revision.
    • removeSlot() - removes the slot with the given role.
  • setOriginalRevisionId() - set the ID of an earlier revision that is being repeated or restored by the current update.
  • getEditResult() - returns the EditResult associated with the current PageUpdater instance.
  • Marking/tagging
    • See setFlags() above.
    • markAsRevert() - mark an edit as a revert and add relevant information
    • addTag() - add a tag to the current update.
      • addTags() - add tags to the current update.
      • addSoftwareTag() - sets software tag to current update.
    • getExplicitTags() - get a list of tags set using the addTag() method.

See also[edit]