2006-05-12 08:14:57 +00:00
|
|
|
<?php
|
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
|
|
|
/**
|
2008-07-21 17:06:35 +00:00
|
|
|
* Delete one or more revisions by moving them to the archive table.
|
2008-07-19 12:15:07 +00:00
|
|
|
*
|
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-07-08 20:47:27 +00:00
|
|
|
* @file
|
2009-08-02 19:35:17 +00:00
|
|
|
* @ingroup Maintenance
|
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
|
|
|
*/
|
|
|
|
|
|
2013-05-17 00:16:59 +00:00
|
|
|
require_once __DIR__ . '/Maintenance.php';
|
2009-06-24 02:49:24 +00:00
|
|
|
|
2012-07-08 20:47:27 +00:00
|
|
|
/**
|
|
|
|
|
* Maintenance script that deletes one or more revisions by moving them
|
|
|
|
|
* to the archive table.
|
|
|
|
|
*
|
|
|
|
|
* @ingroup Maintenance
|
|
|
|
|
*/
|
2009-08-02 19:35:17 +00:00
|
|
|
class DeleteRevision extends Maintenance {
|
2010-12-04 03:20:14 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
public function __construct() {
|
|
|
|
|
parent::__construct();
|
2016-01-30 02:48:47 +00:00
|
|
|
$this->addDescription( 'Delete one or more revisions by moving them to the archive table' );
|
2009-08-02 19:35:17 +00:00
|
|
|
}
|
2010-12-04 03:20:14 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
public function execute() {
|
2010-05-22 16:50:39 +00:00
|
|
|
if ( count( $this->mArgs ) == 0 ) {
|
2009-08-02 19:35:17 +00:00
|
|
|
$this->error( "No revisions specified", true );
|
|
|
|
|
}
|
2009-07-22 10:34:15 +00:00
|
|
|
|
2010-05-22 16:50:39 +00:00
|
|
|
$this->output( "Deleting revision(s) " . implode( ',', $this->mArgs ) .
|
2014-04-23 18:08:42 +00:00
|
|
|
" from " . wfWikiID() . "...\n" );
|
2015-12-31 00:07:37 +00:00
|
|
|
$dbw = $this->getDB( DB_MASTER );
|
2010-12-04 03:20:14 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
$affected = 0;
|
|
|
|
|
foreach ( $this->mArgs as $revID ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$dbw->insertSelect( 'archive', [ 'page', 'revision' ],
|
|
|
|
|
[
|
2014-04-23 18:08:42 +00:00
|
|
|
'ar_namespace' => 'page_namespace',
|
|
|
|
|
'ar_title' => 'page_title',
|
|
|
|
|
'ar_page_id' => 'page_id',
|
|
|
|
|
'ar_comment' => 'rev_comment',
|
|
|
|
|
'ar_user' => 'rev_user',
|
|
|
|
|
'ar_user_text' => 'rev_user_text',
|
|
|
|
|
'ar_timestamp' => 'rev_timestamp',
|
2009-08-02 19:35:17 +00:00
|
|
|
'ar_minor_edit' => 'rev_minor_edit',
|
2014-04-23 18:08:42 +00:00
|
|
|
'ar_rev_id' => 'rev_id',
|
|
|
|
|
'ar_text_id' => 'rev_text_id',
|
|
|
|
|
'ar_deleted' => 'rev_deleted',
|
|
|
|
|
'ar_len' => 'rev_len',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
[
|
2009-08-02 19:35:17 +00:00
|
|
|
'rev_id' => $revID,
|
|
|
|
|
'page_id = rev_page'
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2014-04-23 18:08:42 +00:00
|
|
|
__METHOD__
|
2009-08-02 19:35:17 +00:00
|
|
|
);
|
|
|
|
|
if ( !$dbw->affectedRows() ) {
|
|
|
|
|
$this->output( "Revision $revID not found\n" );
|
|
|
|
|
} else {
|
|
|
|
|
$affected += $dbw->affectedRows();
|
2014-04-23 09:22:55 +00:00
|
|
|
$pageID = $dbw->selectField(
|
|
|
|
|
'revision',
|
|
|
|
|
'rev_page',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'rev_id' => $revID ],
|
2014-04-23 09:22:55 +00:00
|
|
|
__METHOD__
|
|
|
|
|
);
|
|
|
|
|
$pageLatest = $dbw->selectField(
|
|
|
|
|
'page',
|
|
|
|
|
'page_latest',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'page_id' => $pageID ],
|
2014-04-23 09:22:55 +00:00
|
|
|
__METHOD__
|
|
|
|
|
);
|
2016-02-17 09:09:32 +00:00
|
|
|
$dbw->delete( 'revision', [ 'rev_id' => $revID ] );
|
2009-08-23 09:39:13 +00:00
|
|
|
if ( $pageLatest == $revID ) {
|
2014-04-23 09:22:55 +00:00
|
|
|
$newLatest = $dbw->selectField(
|
|
|
|
|
'revision',
|
|
|
|
|
'rev_id',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'rev_page' => $pageID ],
|
2014-04-23 09:22:55 +00:00
|
|
|
__METHOD__,
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'ORDER BY' => 'rev_timestamp DESC' ]
|
2014-04-23 09:22:55 +00:00
|
|
|
);
|
|
|
|
|
$dbw->update(
|
|
|
|
|
'page',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'page_latest' => $newLatest ],
|
|
|
|
|
[ 'page_id' => $pageID ],
|
2014-04-23 09:22:55 +00:00
|
|
|
__METHOD__
|
|
|
|
|
);
|
2009-08-23 09:39:13 +00:00
|
|
|
}
|
2009-08-02 19:35:17 +00:00
|
|
|
}
|
2009-07-22 10:34:15 +00:00
|
|
|
}
|
2009-08-02 19:35:17 +00:00
|
|
|
$this->output( "Deleted $affected revisions\n" );
|
2006-05-12 08:14:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
$maintClass = "DeleteRevision";
|
2013-05-07 23:00:15 +00:00
|
|
|
require_once RUN_MAINTENANCE_IF_MAIN;
|