3 * Delete one or more revisions by moving them to the archive table.
9 require_once( "Maintenance.php" );
11 class DeleteRevision
extends Maintenance
{
13 public function __construct() {
14 parent
::__construct();
15 $this->mDescription
= "Delete one or more revisions by moving them to the archive table";
18 public function execute() {
19 if( count( $this->mArgs
) == 0 ) {
20 $this->error( "No revisions specified", true );
23 $this->output( "Deleting revision(s) " . implode( ',', $this->mArgs
) .
24 " from " . wfWikiID() . "...\n" );
25 $dbw = wfGetDB( DB_MASTER
);
28 foreach ( $this->mArgs
as $revID ) {
29 $dbw->insertSelect( 'archive', array( 'page', 'revision' ),
31 'ar_namespace' => 'page_namespace',
32 'ar_title' => 'page_title',
33 'ar_comment' => 'rev_comment',
34 'ar_user' => 'rev_user',
35 'ar_user_text' => 'rev_user_text',
36 'ar_timestamp' => 'rev_timestamp',
37 'ar_minor_edit' => 'rev_minor_edit',
38 'ar_rev_id' => 'rev_id',
39 'ar_text_id' => 'rev_text_id',
45 if ( !$dbw->affectedRows() ) {
46 $this->output( "Revision $revID not found\n" );
48 $affected +
= $dbw->affectedRows();
49 $dbw->delete( 'revision', array( 'rev_id' => $revID ) );
52 $this->output( "Deleted $affected revisions\n" );
56 $maintClass = "DeleteRevision";
57 require_once( DO_MAINTENANCE
);