From 5c58613f4d77fa214830caced95948e057c0c69e Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 7 Jan 2009 02:41:03 +0000 Subject: [PATCH] Pulling back r45388 "Don't needlessly shy from reuniting lost files with their description pages." I'm staring at this code and my brain just ain't liking it. :) Can we maybe just make the logic cleaner? --- maintenance/cleanupImages.php | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/maintenance/cleanupImages.php b/maintenance/cleanupImages.php index 0fe62440a5..00903f2222 100644 --- a/maintenance/cleanupImages.php +++ b/maintenance/cleanupImages.php @@ -114,23 +114,9 @@ class ImageCleanup extends TableCleanup { $db = wfGetDB( DB_MASTER ); $version = 0; $final = $new; - $has_page = Title::makeTitle( NS_FILE, $orig )->exists(); - while( true ) { - $test = $db->selectField( 'image', 'img_name', array( 'img_name' => $final ), __METHOD__ ); - $conflict = ( $test !== false ); - - if( !$conflict && ( $has_page || $version > 0 ) ) { - // If the file has a description page, don't try to move it to a - // title that already has one. But if we have a misnamed file - // with no corresponding page, and there just happens to exist a - // page with no file at the corrected title, it's probably not a - // coincidence and we shouldn't shy from reuniting them. - $conflict = Title::makeTitle( NS_FILE, $final )->exists(); - } - if( !$conflict ) { - break; - } + while( $db->selectField( 'image', 'img_name', array( 'img_name' => $final ), __METHOD__ ) || + Title::makeTitle( NS_FILE, $final )->exists() ) { $this->log( "Rename conflicts with '$final'..." ); $version++; $final = $this->appendTitle( $new, "_$version" ); -- 2.20.1