Every picture that's uploaded for any user gets the name "picture-.jpg", which means successive user pictures overwrite each other.

Attached patch adds the user ID into the picture name.

CommentFileSizeAuthor
user-picture-upload.patch546 bytesEric Scouten
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

JonBob’s picture

I can't check this easily, because I don't use this feature, but...

The file upload system is supposed to ensure that files never overwrite one another, by appending numbers to the end of file names when necessary to avoid collisions. Is this happening in this case? If so, there is no bug; if not, the bug is probably in file.inc and should not be worked around in user.module IMO.

Eric Scouten’s picture

No, in my case, the file_save_upload function is dying when it can't overwrite the existing file. (Due to the way I do backups, etc., the image files get set to read-only. You could argue that having things be read-only is a problem, but IMHO it shouldn't even be *attempting* to write to the existing file.)

Also, in the original version of user.module, there was a clear attempt to include the user's ID number in the picture file name, but this attempt was failing. (See the line immediately following my patch's insertion.)

So it may be the case that there are in fact *two* bugs: one that the file upload system isn't doing collision avoidance as you expected, and two that the user.module isn't appending user IDs as expected. Let's keep this bug open to represent bug #2. Not being super familiar with the file upload system, I'll leave it to someone else (JonBob?) to decide if a separate bug should be filed for #1.

ccourtne’s picture

Actually there are probably three bugs. As described before the file api will change the filename if it already exists. Unfortunately it will not tell the calling module what it changed the name to. Therefore the user.module will reference the wrong filename and the wrong image will be displayed.

Dries’s picture

Committed Eric's patch. Thanks. Marking this 'active' rather than 'fixed'.

Anonymous’s picture