Localisation updates from https://translatewiki.net.
[mediawiki.git] / maintenance / deleteArchivedRevisions.php
blob13506ab712318dbfc2ce7f02cce23cc68c16a4b7
1 <?php
2 /**
3 * Delete archived (deleted from public) revisions from the database
5 * Shamelessly stolen from deleteOldRevisions.php by Rob Church :)
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * http://www.gnu.org/copyleft/gpl.html
22 * @file
23 * @ingroup Maintenance
26 use MediaWiki\Maintenance\Maintenance;
28 // @codeCoverageIgnoreStart
29 require_once __DIR__ . '/Maintenance.php';
30 // @codeCoverageIgnoreEnd
32 /**
33 * Maintenance script to delete archived (deleted from public) revisions
34 * from the database.
36 * @ingroup Maintenance
38 class DeleteArchivedRevisions extends Maintenance {
39 public function __construct() {
40 parent::__construct();
41 $this->addDescription(
42 "Deletes all archived revisions\nThese revisions will no longer be restorable" );
43 $this->addOption( 'delete', 'Performs the deletion' );
46 public function execute() {
47 $dbw = $this->getPrimaryDB();
49 if ( !$this->hasOption( 'delete' ) ) {
50 $count = $dbw->newSelectQueryBuilder()
51 ->select( 'COUNT(*)' )
52 ->from( 'archive' )
53 ->caller( __METHOD__ )
54 ->fetchField();
55 $this->output( "Found $count revisions to delete.\n" );
56 $this->output( "Please run the script again with the --delete option "
57 . "to really delete the revisions.\n" );
58 return;
61 $this->output( "Deleting archived revisions..." );
62 $dbw->newDeleteQueryBuilder()
63 ->deleteFrom( 'archive' )
64 ->where( '*' )
65 ->caller( __METHOD__ )->execute();
66 $count = $dbw->affectedRows();
67 $this->output( "done. $count revisions deleted.\n" );
69 if ( $count ) {
70 $this->purgeRedundantText( true );
75 // @codeCoverageIgnoreStart
76 $maintClass = DeleteArchivedRevisions::class;
77 require_once RUN_MAINTENANCE_IF_MAIN;
78 // @codeCoverageIgnoreEnd