4 * Deletes a batch of pages
5 * Usage: php deleteBatch.php [-u <user>] [-r <reason>] [-i <interval>] [listfile]
7 * [listfile] is a file where each line contains the title of a page to be
8 * deleted, standard input is used if listfile is not given.
9 * <user> is the username
10 * <reason> is the delete reason
11 * <interval> is the number of seconds to sleep for after each delete
14 * @ingroup Maintenance
18 $optionsWithArgs = array( 'u', 'r', 'i' );
19 require_once( 'commandLine.inc' );
25 $filename = 'php://stdin';
26 $user = 'Delete page script';
30 if ( isset( $args[0] ) ) {
33 if ( isset( $options['u'] ) ) {
34 $user = $options['u'];
36 if ( isset( $options['r'] ) ) {
37 $reason = $options['r'];
39 if ( isset( $options['i'] ) ) {
40 $interval = $options['i'];
43 $wgUser = User
::newFromName( $user );
46 # Setup complete, now start
48 $file = fopen( $filename, 'r' );
50 print "Unable to read file, exiting\n";
54 $dbw = wfGetDB( DB_MASTER
);
56 for ( $linenum = 1; !feof( $file ); $linenum++
) {
57 $line = trim( fgets( $file ) );
61 $page = Title
::newFromText( $line );
62 if ( is_null( $page ) ) {
63 print "Invalid title '$line' on line $linenum\n";
66 if( !$page->exists() ) {
67 print "Skipping nonexistent page '$line'\n";
72 print $page->getPrefixedText();
74 if( $page->getNamespace() == NS_FILE
) {
75 $art = new ImagePage( $page );
76 $img = wfFindFile( $art->mTitle
);
77 if( !$img ||
!$img->delete( $reason ) ) {
78 print "FAILED to delete image file... ";
81 $art = new Article( $page );
83 $success = $art->doDeleteArticle( $reason );
84 $dbw->immediateCommit();
88 print " FAILED to delete image page\n";