Page MenuHomePhabricator

Reuploading a file saves to source file name (regression)
Closed, ResolvedPublic

Description

Reuploading a file saves the file under the source name, not under the name of the already existing file.

It appears that the problem is the disabled wpDestFile field. Apparently at least Firefox 3.0.5 does not send that disabled field upon submit, and SpecialUpload.php thus reverts to using the source name instead (lines 403-407 in r46444).

Enabling the wpDestFile field just before submitting cured the problem in my tests.

Test case: go to [[File:Albert_Einstein_by_Suse_Byk.png]] at the English Wikipedia. Click the "Upload new version of this file" link. Choose as the source file a file named HCC.png from your local disk. Enter "Foo" as the upload comment. Click "Upload". You'll end up uploading [[File:HCC.png]].


Version: unspecified
Severity: major

Details

Reference
bz17200

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:29 PM
bzimport set Reference to bz17200.
bzimport added a subscriber: Unknown Object (MLST).

According to http://www.w3.org/TR/html401/interact/forms.html#h-17.12 this is standard behavior. Disabled controls do not get submitted (they're never "successful", see http://www.w3.org/TR/html401/interact/forms.html#successful-controls ). It appears the proper fix would be to change that field from disabled to readonly (line 1124, maybe also line 1107 for uploads by URL?).

Hm, maybe readonly isn't good either. They still get the focus... maybe add the
desired (fixed) destination file name in an additional hidden input field?

mike.lifeguard+bugs wrote:

*** Bug 17193 has been marked as a duplicate of this bug. ***

Erm, Aaron, did you test? See my comment above: readonly fields still get the focus. On FF 3.0.5, I can even edit the field if I set it to readonly via JS (though I didn't check what happens with my edits). That's hyper-confusing.

Oh, and bug 17193 is *not* a dupe of this one. (Which Mike corrected over there, but I thought it'd be worth pointing out here, too.)

Yes, I tested it on my local install. It fixes the issue of not submitting the data.

OK, not sure how worry I am about custom JS. I'll play around with it a bit.

I'm not able to edit the readonly field.

(In reply to comment #8)

I'm not able to edit the readonly field.

Closing. If there is some weird JS issue, then that is a separate bug.

(In reply to comment #4)

Fixed in r46475

This still has some minor UI issues: the read-only field remains focusable (as Lupo notes above) and gives no visual indication of being uneditable -- it just doesn't react to typing, quite probably making some users wonder if their browser has a bug or something.

We could gray it out with CSS and give it a high tabindex or something, but I think an even better solution would be to just make the field hidden and replace it with plain text: that way it's obvious to anyone that it can't be changed.

hmm, FF (3) seems to grey it out already

(In reply to comment #10)

(In reply to comment #4)

Fixed in r46475

This still has some minor UI issues: the read-only field remains focusable (as
Lupo notes above) and gives no visual indication of being uneditable -- it just
doesn't react to typing, quite probably making some users wonder if their
browser has a bug or something.

Broke out to bug 17707.