Manual:Revision
The concept of page revisions, the notion that wiki pages have revisions which can be referenced, compared, reverted, etc., is one of the most important and recognisable features of MediaWiki's architecture. A page revision represents a wiki page at a particular stage in the history of its contents and of particular actions performed on it.
Every wiki page has at least one revision, which is made at the time a page is created. Every edit to a page creates a new revision row in the database, including a new revision id, timestamp and other metadata (see below).
A special type of page edit is the revert, which reverses one or multiple page actions.
Page actions and revisions
editThere are actions other than page edits that create new revision rows. These actions include:
- Page merges
- Page deletions and conversely, page restorations. See this page for user documentation.
- Changing the visibility of deletions (RevisionDelete)
- Patrol events
A page retains its revision history if is renamed/moved.
A special type of revision is the null revision, which is created by specific actions, such as page moves, page imports and changes in page protection. A null revision retains the revision id of its 'parent'.
Database
edit- The
revision
table is the table that holds metadata about page revisions. For each revision, it stores such information as the page of the revision (rev_page
), a unique identifier (rev_id
), the id of the previous revision (rev_parent_id
), a reference to the user who made the edit (rev_actor
), the time at which the edit was made (rev_timestamp
), the article length (rev_len
), a reference to the comment of the revision in the comment table (rev_comment_id
) and whether or not a revision represents a page deletion (rev_deleted
) or a minor edit (rev_minor_edit
). - Tables linked to or from revisions in the
revision
table include:- The
slots
table - holds references to revisions of content slots, along with other revision-specific information such as content models. - The
content
table - The
actor
table
- The
PHP
editPHP classes for creating, handling and retrieving page revisions include the following:
MediaWiki\Revision namespace
editClasses and interfaces |
---|
MediaWiki\Revisionedit
MediaWiki\Storageedit |
Hooks
editSee below.
Maintenance scripts
editHooks and extensions
editHooks
editRevision-related hooks that may be used by extensions include:
- ContentHandlerDefaultModelFor - allows control over which content model a given title will default to.
- RevisionRecordInserted - called after a revision is inserted into the database (replaces RevisionInsertComplete)
- RevisionFromEditComplete - called when a revision was inserted due to an edit, file upload, import or page move.
- RevisionUndeleted - called after an article revision is restored.
- RevisionDataUpdates - called when constructing a list of DeferrableUpdate to be executed to record secondary data about a revision.
Extensions
editWant to know if and how others have been able to use MediaWiki's revision system? The following extensions may serve as examples or inspiration:
- Extensions for content moderation:
- Extension:FlaggedRevs - allows for managing article content by "editor" and "reviewer" classes.
- Extension:Approved Revs - lets admins mark a certain revision as "approved".
- Extension:Moderation - eliminates revisions by vandals.
- Extension:RevisionSlider - Adds a slider interface to the diff view.
See also
edit- Manual:Tags - about change/revision tags
- Manual:Parameters to index.php