2007-05-12 17:56:09 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
2008-07-21 17:06:35 +00:00
|
|
|
* Delete archived (deleted from public) revisions from the database
|
2007-05-12 17:56:09 +00:00
|
|
|
*
|
2012-06-16 20:35:13 +00:00
|
|
|
* Shamelessly stolen from deleteOldRevisions.php by Rob Church :)
|
|
|
|
|
*
|
2009-08-02 19:35:17 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
2012-06-16 20:35:13 +00:00
|
|
|
* @file
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Maintenance
|
2007-05-12 17:56:09 +00:00
|
|
|
*/
|
|
|
|
|
|
2013-05-17 00:16:59 +00:00
|
|
|
require_once __DIR__ . '/Maintenance.php';
|
2007-05-12 17:56:09 +00:00
|
|
|
|
2012-06-16 20:35:13 +00:00
|
|
|
/**
|
|
|
|
|
* Maintenance script to delete archived (deleted from public) revisions
|
|
|
|
|
* from the database.
|
|
|
|
|
*
|
|
|
|
|
* @ingroup Maintenance
|
|
|
|
|
*/
|
2009-08-02 19:35:17 +00:00
|
|
|
class DeleteArchivedRevisions extends Maintenance {
|
|
|
|
|
public function __construct() {
|
|
|
|
|
parent::__construct();
|
2016-01-30 02:48:47 +00:00
|
|
|
$this->addDescription(
|
|
|
|
|
"Deletes all archived revisions\nThese revisions will no longer be restorable" );
|
2009-08-02 19:35:17 +00:00
|
|
|
$this->addOption( 'delete', 'Performs the deletion' );
|
|
|
|
|
}
|
2007-05-12 17:56:09 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
public function execute() {
|
2021-04-29 02:37:11 +00:00
|
|
|
$dbw = $this->getDB( DB_PRIMARY );
|
2014-09-12 05:44:14 +00:00
|
|
|
|
|
|
|
|
if ( !$this->hasOption( 'delete' ) ) {
|
|
|
|
|
$count = $dbw->selectField( 'archive', 'COUNT(*)', '', __METHOD__ );
|
|
|
|
|
$this->output( "Found $count revisions to delete.\n" );
|
2014-04-23 09:22:55 +00:00
|
|
|
$this->output( "Please run the script again with the --delete option "
|
|
|
|
|
. "to really delete the revisions.\n" );
|
2014-09-12 05:44:14 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-21 16:34:05 +00:00
|
|
|
$this->output( "Deleting archived revisions..." );
|
2014-09-12 05:44:14 +00:00
|
|
|
$dbw->delete( 'archive', '*', __METHOD__ );
|
|
|
|
|
$count = $dbw->affectedRows();
|
|
|
|
|
$this->output( "done. $count revisions deleted.\n" );
|
|
|
|
|
|
|
|
|
|
if ( $count ) {
|
|
|
|
|
$this->purgeRedundantText( true );
|
2009-08-02 19:35:17 +00:00
|
|
|
}
|
|
|
|
|
}
|
2007-05-12 17:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
2018-01-13 00:02:09 +00:00
|
|
|
$maintClass = DeleteArchivedRevisions::class;
|
2013-05-07 23:00:15 +00:00
|
|
|
require_once RUN_MAINTENANCE_IF_MAIN;
|