summaryrefslogtreecommitdiff
path: root/maintenance/deleteOrphanedRevisions.inc.php
blob: 707eaf98d8ae750f33b78573ccd9a3d4bae738e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php

/**
 * Support functions for the deleteOrphanedRevisions maintenance script
 *
 * @addtogroup Maintenance
 * @author Rob Church <robchur@gmail.com>
 */

/**
 * Delete one or more revisions from the database
 * Do this inside a transaction
 *
 * @param $id Array of revision id values
 * @param $db Database class (needs to be a master)
 */
function deleteRevisions( $id, &$dbw ) {
	if( !is_array( $id ) )
		$id = array( $id );
	$dbw->delete( 'revision', array( 'rev_id' => $id ), 'deleteRevision' );
}

/**
 * Spit out script usage information and exit
 */
function showUsage() {
	echo( "Finds revisions which refer to nonexisting pages and deletes them from the database\n" );
	echo( "USAGE: php deleteOrphanedRevisions.php [--report]\n\n" );
	echo( " --report : Prints out a count of affected revisions but doesn't delete them\n\n" );
}