r45388 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45387‎ | r45388 | r45389 >
Date:02:36, 4 January 2009
Author:vyznev
Status:reverted (Comments)
Tags:
Comment:
Don't needlessly shy from reuniting lost files with their description pages.
Modified paths:
  • /trunk/phase3/maintenance/cleanupImages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/cleanupImages.php
@@ -114,9 +114,23 @@
115115 $db = wfGetDB( DB_MASTER );
116116 $version = 0;
117117 $final = $new;
 118+ $has_page = Title::makeTitle( NS_FILE, $orig )->exists();
118119
119 - while( $db->selectField( 'image', 'img_name', array( 'img_name' => $final ), __METHOD__ ) ||
120 - Title::makeTitle( NS_FILE, $final )->exists() ) {
 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+ }
121135 $this->log( "Rename conflicts with '$final'..." );
122136 $version++;
123137 $final = $this->appendTitle( $new, "_$version" );

Follow-up revisions

RevisionCommit summaryAuthorDate
r45478Pulling back r45388 "Don't needlessly shy from reuniting lost files with thei...brion02:41, 7 January 2009
r55694redo r45388 (hopefully) more cleanly (see also bug 16916: Unnecessary title d...vyznev13:58, 31 August 2009

Comments

#Comment by Brion VIBBER (talk | contribs)   02:40, 7 January 2009

I'm staring at this code and my brain just ain't liking it. :) Can we maybe just make the logic cleaner?

#Comment by Ilmari Karonen (talk | contribs)   04:09, 7 January 2009

Filed a report on the reason I had for this change as bug 16916, with an attached patch that just might be more to your brain's liking. :) Comments welcome.

Status & tagging log