Skip to:
Content

BuddyPress.org

Opened 14 years ago

Closed 14 years ago

#1231 closed defect (bug) (fixed)

Legacy avatars sometimes shown after upgrade

Reported by: swinton's profile swinton Owned by:
Milestone: 1.5 Priority: major
Severity: Version:
Component: Core Keywords: avatars legacy bp-core
Cc:

Description

After an upgrade (from 1.0.3 to 1.1.1), legacy avatars are sometimes shown for users even after they have uploaded a new avatar.

The order in which avatars are read from the filesystem is unpredictable, since readdir returns files in the order in which they are stored by the filesystem, not necessarily in reverse chronological order, which is the desired functionality.

A cross-platform fix, which still uses readdir, is attached.

Basically we use an array to define the relative priorities of the avatars we wish to fetch:

  1. -bpfull / -bpthumb
  2. -avatar2 / -avatar1
  3. -groupavatar-full / -groupavatar-thumb

We loop over the array of 'avatar suffixes' and break as soon as one is found.

One drawback of this approach is that we may open a dir handle and read from the filesystem up to 3 times, which isn't great.

It would probably be better if the latest avatar was stored as meta data in wp_usermeta, but this fix is provided as a workaround in the meantime...

Attachments (1)

bp-core-avatars.patch (1.8 KB) - added by swinton 14 years ago.

Download all attachments as: .zip

Change History (9)

#1 @DJPaul
14 years ago

I'm not sure why we even want to be storing old avatar images. There is 'bp_core_avatar_' fields on the usermeta table but I'm not sure if these are old or current. Certainly a usermeta record is the way to go; maybe make this a Wordpress transient?

#2 @apeatling
14 years ago

Database usage for avatars is deprecated, there is no need to touch the database to fetch an image.

#3 @apeatling
14 years ago

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in trunk.

#4 @r-a-y
14 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Just experienced this on a BP setup after upgrading from BP 1.0.3 to BP 1.1.3 to BP 1.2.1.

Swinton is right, the order in which bp_core_fetch_avatar() is unpredictable.

I believe either using Swinton's patch or updating bp_core_delete_existing_avatar() to remove legacy avatars after uploading a new one is the way to go.

#5 @r-a-y
14 years ago

The other option is to rename all avatar files that have "-avatar1" and "-avatar2" to "-bpthumb" and "-bpfull" respectively.

#6 @r-a-y
14 years ago

  • Milestone changed from 1.2 to 1.2.2

#7 @apeatling
14 years ago

  • Milestone changed from 1.2.2 to 1.3

#8 @johnjamesjacoby
14 years ago

  • Component set to Core
  • Resolution set to fixed
  • Status changed from reopened to closed

Fixed in 1.2 branch.

Note: See TracTickets for help on using tickets.