Handle one part of bug 32545 while improving MediaWiki's support for Microdata in...
[mediawiki.git] / maintenance / deleteArchivedRevisions.inc
blob7628985cb450c6ca30e67369c5cbd63a2c3098a5
1 <?php
3 /**
4  * Delete archived (deleted from public) revisions from the database
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  * http://www.gnu.org/copyleft/gpl.html
20  *
21  * @ingroup Maintenance
22  */
24 class DeleteArchivedRevisionsImplementation {
26         /**
27          * Perform the delete on archived revisions.
29          * @param $maint Object An object (typically of class Maintenance)
30          * that implements two methods: handleOutput() and
31          * purgeRedundantText().  See Maintenance for a description of
32          * those methods.
33          */
34         static public function doDelete( $maint ) {
35                 $dbw = wfGetDB( DB_MASTER );
37                 $dbw->begin();
39                 $tbl_arch = $dbw->tableName( 'archive' );
41                 # Delete as appropriate
42                 $maint->handleOutput( "Deleting archived revisions... " );
43                 $dbw->query( "DELETE FROM $tbl_arch" );
45                 $count = $dbw->affectedRows();
46                 $deletedRows = $count != 0;
48                 $maint->handleOutput( "done. $count revisions deleted.\n" );
50                 # This bit's done
51                 # Purge redundant text records
52                 $dbw->commit();
53                 if ( $deletedRows ) {
54                         $maint->purgeRedundantText( true );
55                 }
56         }