Use addDescription() instead of accessing mDescription directly
[lhc/web/wiklou.git] / maintenance / cleanupImages.php
index 1bd0217..0110685 100644 (file)
@@ -42,7 +42,7 @@ class ImageCleanup extends TableCleanup {
 
        public function __construct() {
                parent::__construct();
-               $this->mDescription = "Script to clean up broken, unparseable upload filenames";
+               $this->addDescription( 'Script to clean up broken, unparseable upload filenames' );
        }
 
        protected function processRow( $row ) {
@@ -102,7 +102,7 @@ class ImageCleanup extends TableCleanup {
                        $this->output( "DRY RUN: would delete bogus row '$name'\n" );
                } else {
                        $this->output( "deleting bogus row '$name'\n" );
-                       $db = wfGetDB( DB_MASTER );
+                       $db = $this->getDB( DB_MASTER );
                        $db->delete( 'image',
                                array( 'img_name' => $name ),
                                __METHOD__ );
@@ -139,7 +139,7 @@ class ImageCleanup extends TableCleanup {
                        return;
                }
 
-               $db = wfGetDB( DB_MASTER );
+               $db = $this->getDB( DB_MASTER );
 
                /*
                 * To prevent key collisions in the update() statements below,
@@ -167,7 +167,7 @@ class ImageCleanup extends TableCleanup {
                } else {
                        $this->output( "renaming $path to $finalPath\n" );
                        // @todo FIXME: Should this use File::move()?
-                       $db->begin( __METHOD__ );
+                       $this->beginTransaction( $db, __METHOD__ );
                        $db->update( 'image',
                                array( 'img_name' => $final ),
                                array( 'img_name' => $orig ),
@@ -184,16 +184,16 @@ class ImageCleanup extends TableCleanup {
                        if ( !file_exists( $dir ) ) {
                                if ( !wfMkdirParents( $dir, null, __METHOD__ ) ) {
                                        $this->output( "RENAME FAILED, COULD NOT CREATE $dir" );
-                                       $db->rollback( __METHOD__ );
+                                       $this->rollbackTransaction( $db, __METHOD__ );
 
                                        return;
                                }
                        }
                        if ( rename( $path, $finalPath ) ) {
-                               $db->commit( __METHOD__ );
+                               $this->commitTransaction( $db, __METHOD__ );
                        } else {
                                $this->error( "RENAME FAILED" );
-                               $db->rollback( __METHOD__ );
+                               $this->rollbackTransaction( $db, __METHOD__ );
                        }
                }
        }