* add uniwiki/CreatePage extension to core
[lhc/web/wiklou.git] / maintenance / deleteBatch.php
index 6821ee2..5aeea78 100644 (file)
@@ -1,12 +1,18 @@
 <?php
 
-# delete a batch of pages
-# Usage: php deleteBatch.php [-u <user>] [-r <reason>] [-i <interval>] <listfile>
-# where
-#      <listfile> is a file where each line contains the title of a page to be deleted.
-#      <user> is the username
-#      <reason> is the delete reason
-#      <interval> is the number of seconds to sleep for after each delete
+/**
+ * Deletes a batch of pages
+ * Usage: php deleteBatch.php [-u <user>] [-r <reason>] [-i <interval>] [listfile]
+ * where
+ *     [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.
+ *     <user> is the username
+ *     <reason> is the delete reason
+ *     <interval> is the number of seconds to sleep for after each delete
+ *
+ * @file
+ * @ingroup Maintenance
+ */
 
 $oldCwd = getcwd();
 $optionsWithArgs = array( 'u', 'r', 'i' );
@@ -65,8 +71,12 @@ for ( $linenum = 1; !feof( $file ); $linenum++ ) {
 
        print $page->getPrefixedText();
        $dbw->begin();
-       if( $page->getNamespace() == NS_IMAGE ) {
+       if( $page->getNamespace() == NS_FILE ) {
                $art = new ImagePage( $page );
+               $img = wfFindFile( $art->mTitle );
+               if( !$img || !$img->delete( $reason ) ) {
+                       print "FAILED to delete image file... ";
+               }
        } else {
                $art = new Article( $page );
        }
@@ -75,7 +85,7 @@ for ( $linenum = 1; !feof( $file ); $linenum++ ) {
        if ( $success ) {
                print "\n";
        } else {
-               print " FAILED\n";
+               print " FAILED to delete image page\n";
        }
 
        if ( $interval ) {