summaryrefslogtreecommitdiff
path: root/maintenance/deleteBatch.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2011-06-22 11:28:20 +0200
committerPierre Schmitz <pierre@archlinux.de>2011-06-22 11:28:20 +0200
commit9db190c7e736ec8d063187d4241b59feaf7dc2d1 (patch)
tree46d1a0dee7febef5c2d57a9f7b972be16a163b3d /maintenance/deleteBatch.php
parent78677c7bbdcc9739f6c10c75935898a20e1acd9e (diff)
update to MediaWiki 1.17.0
Diffstat (limited to 'maintenance/deleteBatch.php')
-rw-r--r--maintenance/deleteBatch.php31
1 files changed, 16 insertions, 15 deletions
diff --git a/maintenance/deleteBatch.php b/maintenance/deleteBatch.php
index 56afd86c..c8bb4803 100644
--- a/maintenance/deleteBatch.php
+++ b/maintenance/deleteBatch.php
@@ -26,39 +26,40 @@
*
* @ingroup Maintenance
*/
-
-require_once( dirname(__FILE__) . '/Maintenance.php' );
+
+require_once( dirname( __FILE__ ) . '/Maintenance.php' );
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" );
- $this->addArg( 'listfile', 'File with titles to delete, separated by newlines', false );
+ $this->addArg( 'listfile', 'File with titles to delete, separated by newlines. ' .
+ 'If not given, stdin will be used.', false );
}
-
+
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 );
- if( $this->hasArg() ) {
+ if ( $this->hasArg() ) {
$file = fopen( $this->getArg(), 'r' );
} else {
$file = $this->getStdin();
}
# Setup
- if( !$file ) {
+ if ( !$file ) {
$this->error( "Unable to read file, exiting", true );
}
$wgUser = User::newFromName( $user );
@@ -75,18 +76,18 @@ class DeleteBatch extends Maintenance {
$this->output( "Invalid title '$line' on line $linenum\n" );
continue;
}
- if( !$page->exists() ) {
+ if ( !$page->exists() ) {
$this->output( "Skipping nonexistent page '$line'\n" );
continue;
}
-
-
+
+
$this->output( $page->getPrefixedText() );
$dbw->begin();
- if( $page->getNamespace() == NS_FILE ) {
+ if ( $page->getNamespace() == NS_FILE ) {
$art = new ImagePage( $page );
$img = wfFindFile( $art->mTitle );
- if( !$img || !$img->delete( $reason ) ) {
+ if ( !$img || !$img->delete( $reason ) ) {
$this->output( "FAILED to delete image file... " );
}
} else {
@@ -99,7 +100,7 @@ class DeleteBatch extends Maintenance {
} else {
$this->output( " FAILED to delete article\n" );
}
-
+
if ( $interval ) {
sleep( $interval );
}
@@ -109,4 +110,4 @@ class DeleteBatch extends Maintenance {
}
$maintClass = "DeleteBatch";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );