Fix for r47482: put the RELEASE-NOTES entry in the "bug fixes" section and not the...
[mediawiki.git] / maintenance / deleteRevision.php
blob0c203ab050c8a3747bf98a49c3ac00de05ea5601
1 <?php
2 /**
3 * Delete one or more revisions by moving them to the archive table.
5 * @file
6 * @ingroup Maintenance
7 */
9 require_once( 'commandLine.inc' );
11 $dbw = wfGetDB( DB_MASTER );
13 if ( count( $args ) == 0 ) {
14 echo "Usage: php deleteRevision.php <revid> [<revid> ...]\n";
15 exit(1);
18 echo "Deleting revision(s) " . implode( ',', $args ) . " from ".wfWikiID()."...\n";
20 $affected = 0;
21 foreach ( $args as $revID ) {
22 $dbw->insertSelect( 'archive', array( 'page', 'revision' ),
23 array(
24 'ar_namespace' => 'page_namespace',
25 'ar_title' => 'page_title',
26 'ar_comment' => 'rev_comment',
27 'ar_user' => 'rev_user',
28 'ar_user_text' => 'rev_user_text',
29 'ar_timestamp' => 'rev_timestamp',
30 'ar_minor_edit' => 'rev_minor_edit',
31 'ar_rev_id' => 'rev_id',
32 'ar_text_id' => 'rev_text_id',
33 ), array(
34 'rev_id' => $revID,
35 'page_id = rev_page'
36 ), $fname
38 if ( !$dbw->affectedRows() ) {
39 echo "Revision $revID not found\n";
40 } else {
41 $affected += $dbw->affectedRows();
42 $dbw->delete( 'revision', array( 'rev_id' => $revID ) );
46 print "Deleted $affected revisions\n";