Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
24 / 24 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
DeleteArchivedRevisions | |
100.00% |
24 / 24 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
execute | |
100.00% |
20 / 20 |
|
100.00% |
1 / 1 |
3 |
1 | <?php |
2 | /** |
3 | * Delete archived (deleted from public) revisions from the database |
4 | * |
5 | * Shamelessly stolen from deleteOldRevisions.php by Rob Church :) |
6 | * |
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. |
11 | * |
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. |
16 | * |
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 |
21 | * |
22 | * @file |
23 | * @ingroup Maintenance |
24 | */ |
25 | |
26 | use MediaWiki\Maintenance\Maintenance; |
27 | |
28 | // @codeCoverageIgnoreStart |
29 | require_once __DIR__ . '/Maintenance.php'; |
30 | // @codeCoverageIgnoreEnd |
31 | |
32 | /** |
33 | * Maintenance script to delete archived (deleted from public) revisions |
34 | * from the database. |
35 | * |
36 | * @ingroup Maintenance |
37 | */ |
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' ); |
44 | } |
45 | |
46 | public function execute() { |
47 | $dbw = $this->getPrimaryDB(); |
48 | |
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; |
59 | } |
60 | |
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" ); |
68 | |
69 | if ( $count ) { |
70 | $this->purgeRedundantText( true ); |
71 | } |
72 | } |
73 | } |
74 | |
75 | // @codeCoverageIgnoreStart |
76 | $maintClass = DeleteArchivedRevisions::class; |
77 | require_once RUN_MAINTENANCE_IF_MAIN; |
78 | // @codeCoverageIgnoreEnd |