Last modified: 2008-02-25 10:11:24 UTC
Hi, A user at Commons reported getting an inappropriate warning: When I do a trial upload of one image, I get an error "a file with a similar name already exists, choose another filename". Unfortunately the file that already exists is "drosera.jpg" (not my picture) and that blocks my "drosera.spatulata.flower.x16.jpg" and it will block all other Drosera images too. I believe this is [[MediaWiki:fileexists-extension]] was introduced in r25481. I believe it is caused because of this previous line in SpecialUpload.php: list( $partname, $rawExtension ) = explode( '.', $file->getName(), 2 ); So in this case I think we have $partname = 'drosera', $rawExtension = 'spatulata'. f ( $rawExtension != $file->getExtension() ) { 474 $nt_lc = Title::newFromText( $partname . '.' . strtolower( $ext ) ); // We're not using the normalized form of the extension. 475 // Normal form is lowercase, using most common of alternate 476 // extensions (eg 'jpg' rather than 'JPEG'). 477 // 478 // Check for another file using the normalized form... 479 $nt_lc = Title::newFromText( $partname . '.' . $file->getExtension() ); then since 'spatulata' != 'jpg', the new title ends up being 'drosera.jpg'. Hence the inappropriate error. If '.' was not allowed in image titles that would work fine. To fix it I suppose you could either do a regex string split thing, or else, do the explode and then join all but the last one back up again to form $partname.
Well the warning message sort of answers your question. It says "a file with a SIMILAR name already exists, choose another filename". If you press the ignore button, the file will be saves, with the exact name you provided, and it DOESN'T overwrite the other file (which is a "similar" but not identical) name. Please let us know if you've got your answer here.
No, that's not the issue, Huji. The issue is that exploding based on the occurrence of '.' in the file name is the wrong way to find the extension. We should be going BACK from the end, rather than FORWARD from the beginning. I'm working on a patch for this now.
Oops! Sorry for my misunderstanding. Hopefully, the fix with be easy to achieve since PHP has lots of string functions which go backward in a string (although RegExp is an option too).
Fixed in r31246.