Bug #688

Old avatars are not deleted

Added by Stefan T. about 2 years ago. Updated about 2 years ago.

Status:Closed Start date:01/20/2010
Priority:Normal Due date:
Assignee:Huji Lee % Done:

100%

Category:User Control Panel
Target version:1.4.12
Reproducibility:Always Database Type:
Reported In MyBB Version:1.4.11 Database Version:
PHP Version: SQA assignments:
Browser:

Description

If you upload a new avatar with an other extension of the current avatar, both avatars will exist on the server. Perhaps we should remove the old one first.

Associated revisions

Revision 4728
Added by Huji Lee about 2 years ago

Fixes Old avatars are not deleted (fixes: 688)

History

Updated by Huji Lee about 2 years ago

  • Status changed from New to Confirmed
  • Assignee set to Huji Lee

Updated by Huji Lee about 2 years ago

Having had a look at the code, I can say the uploaded avatar is also not deleted when the user changes his avatar from an uploaded one to one from the gallery.

In general, a file cleanup function should be called after avatar changes.

For version 2.0, I suggest we avoid our current approach of storing the whole file path + dateline in one field of the database. Instead, two columns like "filename" and "dateline" should b used, and the "./uploads/avatars/" prefix should be added by the code.

Updated by Tom Moore about 2 years ago

Huji Lee wrote:

For version 2.0, I suggest we avoid our current approach of storing the whole file path + dateline in one field of the database. Instead, two columns like "filename" and "dateline" should b used, and the "./uploads/avatars/" prefix should be added by the code.

What if the Avatar Path is changed? Adding the dateline to the end of the filename will force a browser to reload the image if the user changes it, instead of caching it.

Updated by Huji Lee about 2 years ago

Tom Moore wrote:

What if the Avatar Path is changed?

There are two approaches: 1) We keep old avatars in the old address and keep the old address in the database too (our current version already does the second part). 2) We "move" old avatars to the new path (which won't require storing relative paths in the database for every avatar).

Adding the dateline to the end of the filename will force a browser to reload the image if the user changes it, instead of caching it.

I never said we shouldn't add datelines; what I say is we shouldn't have a field in our database containing a value like './uploads/avatars/avatar_1.gif?dateline=1264062284' but instead, we should have a field containing 'avatar_1.gif' and one containing '1264062284'. Then, our PHP code should join them and add the directory address prefix ('./uploads/avatars/').

Updated by Ryan Gordon about 2 years ago

So basically, all that should be changed here is removing of the old one, if the extension is different AFTER the new one is uploaded. There is no need to remove the old one if it's just going to be overwritten. Also, we don't want to do it pre-upload because if there's an error uploading the new avatar, the old avatar will be lost.

Further changes and discussion on 2.0 should be kept internal.

Updated by Huji Lee about 2 years ago

  • Target version set to 1.4.12

Updated by Huji Lee about 2 years ago

  • Status changed from Confirmed to Resolved
  • % Done changed from 0 to 100

Applied in changeset r4728.

Updated by Stefan T. about 2 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF