X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FdeleteArchivedRevisions.php;h=905b5d9c080095ab5da1772d5ca6322ad7e9d9f8;hb=08e0ed2b70ba5986a96c701f84a7679c98a6f2fd;hp=30883ba4f595ac6f4571ccbe1be71ad064dddbca;hpb=9392d01c4e95be3c156ad594d8a8b6aa678daa7d;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/deleteArchivedRevisions.php b/maintenance/deleteArchivedRevisions.php index 30883ba4f5..905b5d9c08 100644 --- a/maintenance/deleteArchivedRevisions.php +++ b/maintenance/deleteArchivedRevisions.php @@ -21,11 +21,9 @@ * * @file * @ingroup Maintenance - * @author Aaron Schulz */ require_once __DIR__ . '/Maintenance.php'; -require_once __DIR__ . '/deleteArchivedRevisions.inc'; /** * Maintenance script to delete archived (deleted from public) revisions @@ -36,26 +34,29 @@ require_once __DIR__ . '/deleteArchivedRevisions.inc'; class DeleteArchivedRevisions extends Maintenance { public function __construct() { parent::__construct(); - $this->mDescription = - "Deletes all archived revisions\nThese revisions will no longer be restorable"; + $this->addDescription( + "Deletes all archived revisions\nThese revisions will no longer be restorable" ); $this->addOption( 'delete', 'Performs the deletion' ); } - public function handleOutput( $str ) { - $this->output( $str ); - } - public function execute() { - $this->output( "Delete archived revisions\n\n" ); - # Data should come off the master, wrapped in a transaction - if ( $this->hasOption( 'delete' ) ) { - DeleteArchivedRevisionsImplementation::doDelete( $this ); - } else { - $dbw = wfGetDB( DB_MASTER ); - $res = $dbw->selectRow( 'archive', 'COUNT(*) as count', array(), __FUNCTION__ ); - $this->output( "Found {$res->count} revisions to delete.\n" ); + $dbw = $this->getDB( DB_MASTER ); + + if ( !$this->hasOption( 'delete' ) ) { + $count = $dbw->selectField( 'archive', 'COUNT(*)', '', __METHOD__ ); + $this->output( "Found $count revisions to delete.\n" ); $this->output( "Please run the script again with the --delete option " . "to really delete the revisions.\n" ); + return; + } + + $this->output( "Deleting archived revisions... " ); + $dbw->delete( 'archive', '*', __METHOD__ ); + $count = $dbw->affectedRows(); + $this->output( "done. $count revisions deleted.\n" ); + + if ( $count ) { + $this->purgeRedundantText( true ); } } }