This page (work in progress) is not a guide but it is meant as a starting point for developers to explore the subject on this site. For general, user-oriented information on the topic of page revisions, see e.g. Help:History.

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 edit

There are actions other than page edits that create new revision rows. These actions include:

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:

PHP edit

PHP classes for creating, handling and retrieving page revisions include the following:

MediaWiki\Revision namespace edit

Classes and interfaces

MediaWiki\Revision edit

MediaWiki\Storage edit

Hooks edit

See below.

Maintenance scripts edit

Hooks and extensions edit

Hooks edit

Revision-related hooks that may be used by extensions include:

Extensions edit

Want to know if and how others have been able to use MediaWiki's revision system? The following extensions may serve as examples or inspiration:

See also edit