Extension:SpecialDeleteOldRevisions

If you use mediawiki &gt; 1.12, consider using SpecialDeleteOldRevisions2 extension instead. It is curently maintained and fixed for latest wiki release, and you won't have to apply all patches manually.

What is this extension good for?
This extension deletes permanently all old revisions of all article(s). If you are using 1.7 or newer you can alternatively specify articles, otherwise it acts on all articles.

What it does not do: You can not choose a certain revision (check Oversight for that functionality).

This extension adds a special page accessible to sysops only.

Usage (1.7 and newer)
You need to be logged in as sysop. Under special pages you will find the Delete old revision page in the sysop section.


 * page: specify the pages to be deleted, % for all pages.
 * namespace: specify the namespace for the articles, check all for all namespaces.
 * up to date: specify the date of the revisions. All revision before and on that date will be deleted.
 * Delete archived articles: If this is checked all already deleted articles will be permanently deleted.

This extension will clear the tables: archive, page, revision, text, recent changes and logging.

Example: If you want to delete all unused MediaWiki-Texts (which have been deleted after upgrading to 1.8), choose namespace MediaWiki and article name: %. The database will be significantly smaller.

If using MySQL you need to optimize the tables afterwards, you can do that with phpMyAdmin.

Usage (1.6 and older)
You need to be logged in as sysop. Under special pages you will find the Delete old revision page in the sysop section.

You next get a page with a single button to Delete. This will delete all revisions from all pages.

Installation
You can now access the Special:DeleteOldRevisions page as a sysop.
 * 1) Make a file "SpecialDeleteOldRevisions.php" in /extensions with the code on this page.
 * 2) Add the following lines near the end in the LocalSettings.php file:

Code from 1.13.2
To use this extension, do the following to make it work: Now you can download it here
 * create the directory "SpecialDeleteOldRevisions"
 * place the HTMLForm.php from 1.11.2, replacing includes/HTMLForm.php
 * edited line with quotes problem

You just need to put lines $wgGroupPermissions['sysop']['DeleteOldRevisions'] = true; include_once('extensions/SpecialDeleteOldRevisions/SpecialDeleteOldRevisions.php'); in LocalSettings.php - and everything will work fine.

Code from 1.7.x
This code has been tested on MediaWiki 1.9.2. Warning: This code has extended functionality and is still in beta stage. Test in a safe environment and backup your DB!

Download here.

Please use download, it is up to date.

Code through 1.6.x
Note: This code is outdated, it does not have the article selection.

This code has been tested on MediaWiki 1.6.7.

Note: Won't work on MediaWiki 1.7 (Call to deprecated (v1.7) User::isSysop method)
 * Fix: If you find the function User::isSysop in includes/User.php, you will see the new function, albeit commented out. (it is User::isAllowed('protect') on my version.)

History:
 * 20 June 2006 -- Version 1.0 -- First release.

Optimizing tables
After the revisions have been deleted, optimize all tables by checking them all in myPhpAdmin and then in the "With selected:" drop down at the bottom of the page, choose "optimize".

Known issues
If pages have single quotes in their titles, an error will result. This can be fixed:
 * In the code (near line 270), replace
 * $arc[] = "'" . $row->page_title . "'";
 * with
 * $arc[] = $dbw->addQuotes($row->page_title);

This will temporarily fix the bug people are currently stumbling on.