3 # delete a batch of pages
4 # Usage: php deleteBatch.php [-u <user>] [-r <reason>] [-i <interval>] <listfile>
6 # <listfile> is a file where each line contains the title of a page to be deleted.
7 # <user> is the username
8 # <reason> is the delete reason
9 # <interval> is the number of seconds to sleep for after each delete
12 $optionsWithArgs = array( 'u', 'r', 'i' );
13 require_once( 'commandLine.inc' );
19 $filename = 'php://stdin';
20 $user = 'Delete page script';
24 if ( isset( $args[0] ) ) {
27 if ( isset( $options['u'] ) ) {
28 $user = $options['u'];
30 if ( isset( $options['r'] ) ) {
31 $reason = $options['r'];
33 if ( isset( $options['i'] ) ) {
34 $interval = $options['i'];
37 $wgUser = User
::newFromName( $user );
40 # Setup complete, now start
42 $file = fopen( $filename, 'r' );
44 print "Unable to read file, exiting\n";
48 $dbw =& wfGetDB( DB_MASTER
);
50 for ( $linenum = 1; !feof( $file ); $linenum++
) {
51 $line = trim( fgets( $file ) );
55 $page = Title
::newFromText( $line );
56 if ( is_null( $page ) ) {
57 print "Invalid title '$line' on line $linenum\n";
60 if( !$page->exists() ) {
61 print "Skipping nonexistent page '$line'\n";
66 print $page->getPrefixedText();
68 if( $page->getNamespace() == NS_IMAGE
) {
69 $art = new ImagePage( $page );
71 $art = new Article( $page );
73 $success = $art->doDeleteArticle( $reason );
74 $dbw->immediateCommit();