X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FcleanupImages.php;h=915a2c0801a6483f6abe19afdb2cabcda4c88646;hb=82a37b80a00f988536cf5600d7c3c3ce065a97ae;hp=d42497d36299c8883f4f50006385faad825f4bea;hpb=feeac7bdfc9c629e40e5de0b1825daa2bd634a55;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/cleanupImages.php b/maintenance/cleanupImages.php index d42497d362..915a2c0801 100644 --- a/maintenance/cleanupImages.php +++ b/maintenance/cleanupImages.php @@ -56,6 +56,7 @@ class ImageCleanup extends TableCleanup { if ( $source == '' ) { // Ye olde empty rows. Just kill them. $this->killRow( $source ); + return $this->progress( 1 ); } @@ -82,6 +83,7 @@ class ImageCleanup extends TableCleanup { return $this->progress( 0 ); } $this->pokeFile( $source, $safe ); + return $this->progress( 1 ); } @@ -89,6 +91,7 @@ class ImageCleanup extends TableCleanup { $munged = $title->getDBkey(); $this->output( "page $source ($munged) doesn't match self.\n" ); $this->pokeFile( $source, $munged ); + return $this->progress( 1 ); } @@ -96,7 +99,7 @@ class ImageCleanup extends TableCleanup { } /** - * @param $name string + * @param string $name */ private function killRow( $name ) { if ( $this->dryrun ) { @@ -114,6 +117,7 @@ class ImageCleanup extends TableCleanup { if ( !isset( $this->repo ) ) { $this->repo = RepoGroup::singleton()->getLocalRepo(); } + return $this->repo->getRootDirectory() . '/' . $this->repo->getHashPath( $name ) . $name; } @@ -122,7 +126,12 @@ class ImageCleanup extends TableCleanup { } private function pageExists( $name, $db ) { - return $db->selectField( 'page', '1', array( 'page_namespace' => NS_FILE, 'page_title' => $name ), __METHOD__ ); + return $db->selectField( + 'page', + '1', + array( 'page_namespace' => NS_FILE, 'page_title' => $name ), + __METHOD__ + ); } private function pokeFile( $orig, $new ) { @@ -130,6 +139,7 @@ class ImageCleanup extends TableCleanup { if ( !file_exists( $path ) ) { $this->output( "missing file: $path\n" ); $this->killRow( $orig ); + return; } @@ -145,7 +155,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" ); @@ -179,6 +189,7 @@ class ImageCleanup extends TableCleanup { if ( !wfMkdirParents( $dir, null, __METHOD__ ) ) { $this->output( "RENAME FAILED, COULD NOT CREATE $dir" ); $db->rollback( __METHOD__ ); + return; } } @@ -205,6 +216,7 @@ class ImageCleanup extends TableCleanup { $test = Title::makeTitleSafe( NS_FILE, $x ); if ( is_null( $test ) || $test->getDBkey() !== $x ) { $this->error( "Unable to generate safe title from '$name', got '$x'" ); + return false; }