00001 <?php 00002 00026 require_once( dirname(__FILE__) . '/Maintenance.php' ); 00027 00028 class DeleteArchivedRevisions extends Maintenance { 00029 public function __construct() { 00030 parent::__construct(); 00031 $this->mDescription = "Deletes all archived revisions\nThese revisions will no longer be restorable"; 00032 $this->addOption( 'delete', 'Performs the deletion' ); 00033 } 00034 00035 public function execute() { 00036 $this->output( "Delete archived revisions\n\n" ); 00037 # Data should come off the master, wrapped in a transaction 00038 $dbw = wfGetDB( DB_MASTER ); 00039 if( $this->hasOption('delete') ) { 00040 $dbw->begin(); 00041 00042 $tbl_arch = $dbw->tableName( 'archive' ); 00043 00044 # Delete as appropriate 00045 $this->output( "Deleting archived revisions... " ); 00046 $dbw->query( "TRUNCATE TABLE $tbl_arch" ); 00047 00048 $count = $dbw->affectedRows(); 00049 $deletedRows = $count != 0; 00050 00051 $this->output( "done. $count revisions deleted.\n" ); 00052 00053 # This bit's done 00054 # Purge redundant text records 00055 $dbw->commit(); 00056 if( $deletedRows ) { 00057 $this->purgeRedundantText( true ); 00058 } 00059 } else { 00060 $res = $dbw->selectRow( 'archive', 'COUNT(*) as count', array(), __FUNCTION__ ); 00061 $this->output( "Found {$res->count} revisions to delete.\n" ); 00062 $this->output( "Please run the script again with the --delete option to really delete the revisions.\n" ); 00063 } 00064 } 00065 } 00066 00067 $maintClass = "DeleteArchivedRevisions"; 00068 require_once( DO_MAINTENANCE );