Project

General

Profile

Actions

Bug #8813

closed

`cac_activity_secondary_avatar_enlarge()` can generate invalid avatar URLs

Added by Boone Gorges almost 7 years ago. Updated almost 7 years ago.

Status:
Resolved
Priority name:
Normal
Assignee:
Category name:
My Commons
Target version:
Start date:
2017-10-16
Due date:
% Done:

0%

Estimated time:
Deployment actions:

Description

cac_activity_secondary_avatar_enlarge() swaps '-bpthumb' with '-bpfull' to get larger avatars. In some cases, this technique is not reliable, because the -bpfull.jpg and -bpthumb.jpg avatars can be generated with different UUIDs. See https://buddypress.trac.wordpress.org/browser/tags/2.9.1/src/bp-core/classes/class-bp-attachment-avatar.php?marks=287#L278. uniqid() will generate a timestamp based on microtime(), which could tick between generation of bpfull and bpthumb if things are slow enough. See https://secure.php.net/manual/en/function.uniqid.php

We might consider an enhancement in BP that would use a single UUID prefix for both avatar types, but this wouldn't do anything for legacy avatars.

I think the only solution is to do a separate bp_core_fetch_avatar() lookup to get the bpfull avatar. I know this is not ideal from a performance perspective, but I think it's necessary.

I found this while working on #8639, but I'm pretty sure it's an independent issue - a spot-check of a few filenames suggests that it's not uncommon to see differently named bpfull and bpthumb for actual users, and I seem to recall seeing these 404s in the past.

It'd be great to get this into the 1.12 release, but please feel free to push off if you think it needs more research.


Related issues

Related to CUNY Academic Commons - Feature #8639: Add photo upload to registration pageResolvedDaniel Jones2017-08-31

Actions
Actions

Also available in: Atom PDF