X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FcleanupImages.php;h=c8f393d8412c21b991160e2efd58317401fa99ba;hb=3302e11b23301ee55196b372c1cf5ff48a5ab6c3;hp=1bd0217bd8019a9b24a54c5ffeb8a81620014836;hpb=7028f7e31c92ca254ff9af64ff98cd092331b570;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/cleanupImages.php b/maintenance/cleanupImages.php index 1bd0217bd8..c8f393d841 100644 --- a/maintenance/cleanupImages.php +++ b/maintenance/cleanupImages.php @@ -33,16 +33,16 @@ require_once __DIR__ . '/cleanupTable.inc'; * @ingroup Maintenance */ class ImageCleanup extends TableCleanup { - protected $defaultParams = array( + protected $defaultParams = [ 'table' => 'image', - 'conds' => array(), + 'conds' => [], 'index' => 'img_name', 'callback' => 'processRow', - ); + ]; 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,9 +102,9 @@ 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 ), + [ 'img_name' => $name ], __METHOD__ ); } } @@ -118,14 +118,14 @@ class ImageCleanup extends TableCleanup { } private function imageExists( $name, $db ) { - return $db->selectField( 'image', '1', array( 'img_name' => $name ), __METHOD__ ); + return $db->selectField( 'image', '1', [ 'img_name' => $name ], __METHOD__ ); } private function pageExists( $name, $db ) { return $db->selectField( 'page', '1', - array( 'page_namespace' => NS_FILE, 'page_title' => $name ), + [ 'page_namespace' => NS_FILE, 'page_title' => $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,33 +167,33 @@ 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 ), + [ 'img_name' => $final ], + [ 'img_name' => $orig ], __METHOD__ ); $db->update( 'oldimage', - array( 'oi_name' => $final ), - array( 'oi_name' => $orig ), + [ 'oi_name' => $final ], + [ 'oi_name' => $orig ], __METHOD__ ); $db->update( 'page', - array( 'page_title' => $final ), - array( 'page_title' => $orig, 'page_namespace' => NS_FILE ), + [ 'page_title' => $final ], + [ 'page_title' => $orig, 'page_namespace' => NS_FILE ], __METHOD__ ); $dir = dirname( $finalPath ); 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__ ); } } } @@ -206,7 +206,7 @@ class ImageCleanup extends TableCleanup { private function buildSafeTitle( $name ) { $x = preg_replace_callback( '/([^' . Title::legalChars() . ']|~)/', - array( $this, 'hexChar' ), + [ $this, 'hexChar' ], $name ); $test = Title::makeTitleSafe( NS_FILE, $x );