r45478 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45477‎ | r45478 | r45479 >
Date:02:41, 7 January 2009
Author:brion
Status:ok
Tags:
Comment:
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?
Modified paths:
  • /trunk/phase3/maintenance/cleanupImages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/cleanupImages.php
@@ -114,23 +114,9 @@
115115 $db = wfGetDB( DB_MASTER );
116116 $version = 0;
117117 $final = $new;
118 - $has_page = Title::makeTitle( NS_FILE, $orig )->exists();
119118
120 - while( true ) {
121 - $test = $db->selectField( 'image', 'img_name', array( 'img_name' => $final ), __METHOD__ );
122 - $conflict = ( $test !== false );
123 -
124 - if( !$conflict && ( $has_page || $version > 0 ) ) {
125 - // If the file has a description page, don't try to move it to a
126 - // title that already has one. But if we have a misnamed file
127 - // with no corresponding page, and there just happens to exist a
128 - // page with no file at the corrected title, it's probably not a
129 - // coincidence and we shouldn't shy from reuniting them.
130 - $conflict = Title::makeTitle( NS_FILE, $final )->exists();
131 - }
132 - if( !$conflict ) {
133 - break;
134 - }
 119+ while( $db->selectField( 'image', 'img_name', array( 'img_name' => $final ), __METHOD__ ) ||
 120+ Title::makeTitle( NS_FILE, $final )->exists() ) {
135121 $this->log( "Rename conflicts with '$final'..." );
136122 $version++;
137123 $final = $this->appendTitle( $new, "_$version" );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r45388Don't needlessly shy from reuniting lost files with their description pages.vyznev02:36, 4 January 2009

Status & tagging log