X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FdeleteArchivedRevisions.php;h=9924eb0cd569f5c53eaf3e70c141e476c9ff99e9;hb=e25eb30ea81eda82b57a4e3c84f4e1afdf3b6080;hp=ffd581c18adf8ddd42d1abcfe97878c05812b0d8;hpb=3a7e36b2d6f7a77ee1fbc356f277ee4bf0aeb60c;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/deleteArchivedRevisions.php b/maintenance/deleteArchivedRevisions.php index ffd581c18a..9924eb0cd5 100644 --- a/maintenance/deleteArchivedRevisions.php +++ b/maintenance/deleteArchivedRevisions.php @@ -25,7 +25,6 @@ */ require_once __DIR__ . '/Maintenance.php'; -require_once __DIR__ . '/deleteArchivedRevisions.inc'; /** * Maintenance script to delete archived (deleted from public) revisions @@ -36,24 +35,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->mDescription = + "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" ); - $this->output( "Please run the script again with the --delete option to really delete the revisions.\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 ); } } }