Manual:DeleteRevision.php

deleteRevision.php is a maintenance script located in the maintenance directory that can be used to delete one or more revisions by moving them to the archive table. This makes the revision disappear from the public version of the wiki. If this achieves the expected result, the deleteArchivedRevisions.php script can be used to completely remove the revision from the database.

To find the ID of the revision to delete, look at the URL for each date on the history page. It will look something like  http://yourwiki/index.php?title=Page_Title&oldid=1234 . The revision ID is the oldid, 1234 in this example. This revision can be deleted like so:

php maintenance/deleteRevision.php 1234

If you want to remove multiple revisions, separate them with a space:

php maintenance/deleteRevision.php 1234 5678

Deleting the current page revision
This script can also be used to delete the current revision of a page. In this case the script takes care to update the page record to point to the correct revision again: It updates the page_latest field of the according page in the page table. It will sort the available revisions by rev_timestamp and will set page_latest to the revision with the newest timestamp. This makes sure that database integrity is preserved.

Fixing the rev_parent_id field
The script does not update the rev_parent_id field of that revision, which is following the deleted one. That way e.g. size differences in page histories will be calculated incorrectly as MediaWiki still tries to calculate them based on the revision, which got deleted. So it gets a size of 0 bytes for that revision and accordingly a wrong value for the size difference.

Currently this can only be fixed manually by manually updating the rev_parent_id field of the revision, which is following the deleted one. An issue should be created in the bugtracker and this problem be fixed properly.

Until this problem is fixed, the following queries can be used to spot pages with broken rev_parent_id:

This displays a list with the affected pages (rev_page) and the problematic revisions (rev_id). Use the value from rev_page in the following query:

This displays a list of revisions for the according page (here for page 4711), sorted by rev_id. Scroll down to the problematic revision and fix its rev_parent_id value so that it points to the previous revision (rev_id value of the next-older row in the result set).