Bug #8813
closed`cac_activity_secondary_avatar_enlarge()` can generate invalid avatar URLs
0%
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