2006-06-15 04:58:03 +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
|
|
|
* Deletes a batch of pages
|
2009-01-03 16:20:05 +00:00
|
|
|
* Usage: php deleteBatch.php [-u <user>] [-r <reason>] [-i <interval>] [listfile]
|
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
|
|
|
* where
|
2009-01-03 16:20:05 +00:00
|
|
|
* [listfile] is a file where each line contains the title of a page to be
|
|
|
|
|
* deleted, standard input is used if listfile is not given.
|
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
|
|
|
* <user> is the username
|
|
|
|
|
* <reason> is the delete reason
|
|
|
|
|
* <interval> is the number of seconds to sleep for after each delete
|
|
|
|
|
*
|
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
|
|
|
|
|
*
|
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
|
|
|
|
|
*/
|
2009-08-02 19:35:17 +00:00
|
|
|
|
2010-05-22 16:50:39 +00:00
|
|
|
require_once( dirname( __FILE__ ) . '/Maintenance.php' );
|
2009-08-02 19:35:17 +00:00
|
|
|
|
|
|
|
|
class DeleteBatch extends Maintenance {
|
|
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
|
parent::__construct();
|
|
|
|
|
$this->mDescription = "Deletes a batch of pages";
|
|
|
|
|
$this->addOption( 'u', "User to perform deletion", false, true );
|
|
|
|
|
$this->addOption( 'r', "Reason to delete page", false, true );
|
|
|
|
|
$this->addOption( 'i', "Interval to sleep between deletions" );
|
2010-11-20 11:11:20 +00:00
|
|
|
$this->addArg( 'listfile', 'File with titles to delete, separated by newlines. ' .
|
|
|
|
|
'If not given, stdin will be used.', false );
|
2009-06-24 02:49:24 +00:00
|
|
|
}
|
2009-08-02 19:35:17 +00:00
|
|
|
|
|
|
|
|
public function execute() {
|
|
|
|
|
global $wgUser;
|
|
|
|
|
|
|
|
|
|
# Change to current working directory
|
|
|
|
|
$oldCwd = getcwd();
|
|
|
|
|
chdir( $oldCwd );
|
|
|
|
|
|
|
|
|
|
# Options processing
|
|
|
|
|
$user = $this->getOption( 'u', 'Delete page script' );
|
|
|
|
|
$reason = $this->getOption( 'r', '' );
|
|
|
|
|
$interval = $this->getOption( 'i', 0 );
|
2010-05-22 16:50:39 +00:00
|
|
|
if ( $this->hasArg() ) {
|
2009-08-02 19:35:17 +00:00
|
|
|
$file = fopen( $this->getArg(), 'r' );
|
|
|
|
|
} else {
|
|
|
|
|
$file = $this->getStdin();
|
2009-06-24 02:02:37 +00:00
|
|
|
}
|
2009-06-24 02:49:24 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
# Setup
|
2010-05-22 16:50:39 +00:00
|
|
|
if ( !$file ) {
|
2009-08-02 21:55:10 +00:00
|
|
|
$this->error( "Unable to read file, exiting", true );
|
2009-08-02 19:35:17 +00:00
|
|
|
}
|
|
|
|
|
$wgUser = User::newFromName( $user );
|
|
|
|
|
$dbw = wfGetDB( DB_MASTER );
|
|
|
|
|
|
|
|
|
|
# Handle each entry
|
|
|
|
|
for ( $linenum = 1; !feof( $file ); $linenum++ ) {
|
|
|
|
|
$line = trim( fgets( $file ) );
|
|
|
|
|
if ( $line == '' ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$page = Title::newFromText( $line );
|
|
|
|
|
if ( is_null( $page ) ) {
|
|
|
|
|
$this->output( "Invalid title '$line' on line $linenum\n" );
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2010-05-22 16:50:39 +00:00
|
|
|
if ( !$page->exists() ) {
|
2009-08-02 19:35:17 +00:00
|
|
|
$this->output( "Skipping nonexistent page '$line'\n" );
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->output( $page->getPrefixedText() );
|
|
|
|
|
$dbw->begin();
|
2010-05-22 16:50:39 +00:00
|
|
|
if ( $page->getNamespace() == NS_FILE ) {
|
2009-08-02 19:35:17 +00:00
|
|
|
$art = new ImagePage( $page );
|
|
|
|
|
$img = wfFindFile( $art->mTitle );
|
2010-05-22 16:50:39 +00:00
|
|
|
if ( !$img || !$img->delete( $reason ) ) {
|
2009-08-02 19:35:17 +00:00
|
|
|
$this->output( "FAILED to delete image file... " );
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$art = new Article( $page );
|
|
|
|
|
}
|
|
|
|
|
$success = $art->doDeleteArticle( $reason );
|
2009-12-14 23:18:03 +00:00
|
|
|
$dbw->commit();
|
2009-08-02 19:35:17 +00:00
|
|
|
if ( $success ) {
|
|
|
|
|
$this->output( "\n" );
|
|
|
|
|
} else {
|
|
|
|
|
$this->output( " FAILED to delete article\n" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $interval ) {
|
|
|
|
|
sleep( $interval );
|
|
|
|
|
}
|
|
|
|
|
wfWaitForSlaves( 5 );
|
|
|
|
|
}
|
2006-06-15 04:58:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
$maintClass = "DeleteBatch";
|
|
|
|
|
require_once( DO_MAINTENANCE );
|