w/s fixup
[lhc/web/wiklou.git] / maintenance / cleanupImages.php
index 818b9ed..81d1c85 100644 (file)
@@ -73,8 +73,9 @@ class ImageCleanup extends TableCleanup {
                if ( is_null( $title ) ) {
                        $this->output( "page $source ($cleaned) is illegal.\n" );
                        $safe = $this->buildSafeTitle( $cleaned );
-                       if ( $safe === false )
+                       if ( $safe === false ) {
                                return $this->progress( 0 );
+                       }
                        $this->pokeFile( $source, $safe );
                        return $this->progress( 1 );
                }
@@ -86,9 +87,12 @@ class ImageCleanup extends TableCleanup {
                        return $this->progress( 1 );
                }
 
-               $this->progress( 0 );
+               return $this->progress( 0 );
        }
 
+       /**
+        * @param $name string
+        */
        private function killRow( $name ) {
                if ( $this->dryrun ) {
                        $this->output( "DRY RUN: would delete bogus row '$name'\n" );
@@ -120,7 +124,8 @@ class ImageCleanup extends TableCleanup {
                $path = $this->filePath( $orig );
                if ( !file_exists( $path ) ) {
                        $this->output( "missing file: $path\n" );
-                       return $this->killRow( $orig );
+                       $this->killRow( $orig );
+                       return;
                }
 
                $db = wfGetDB( DB_MASTER );
@@ -135,7 +140,7 @@ class ImageCleanup extends TableCleanup {
                $version = 0;
                $final = $new;
                $conflict = ( $this->imageExists( $final, $db ) ||
-                                 ( $this->pageExists( $orig, $db ) && $this->pageExists( $final, $db ) ) );
+                               ( $this->pageExists( $orig, $db ) && $this->pageExists( $final, $db ) ) );
 
                while ( $conflict ) {
                        $this->output( "Rename conflicts with '$final'...\n" );
@@ -150,7 +155,7 @@ class ImageCleanup extends TableCleanup {
                        $this->output( "DRY RUN: would rename $path to $finalPath\n" );
                } else {
                        $this->output( "renaming $path to $finalPath\n" );
-                       // XXX: should this use File::move()?  FIXME?
+                       // @todo FIXME: Should this use File::move()?
                        $db->begin();
                        $db->update( 'image',
                                array( 'img_name' => $final ),
@@ -166,8 +171,8 @@ class ImageCleanup extends TableCleanup {
                                __METHOD__ );
                        $dir = dirname( $finalPath );
                        if ( !file_exists( $dir ) ) {
-                               if ( !wfMkdirParents( $dir ) ) {
-                                       $this->log( "RENAME FAILED, COULD NOT CREATE $dir" );
+                               if ( !wfMkdirParents( $dir, null, __METHOD__ ) ) {
+                                       $this->output( "RENAME FAILED, COULD NOT CREATE $dir" );
                                        $db->rollback();
                                        return;
                                }
@@ -204,4 +209,4 @@ class ImageCleanup extends TableCleanup {
 }
 
 $maintClass = "ImageCleanup";
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );