Skip to:

Re: Plugin: Avatar Upload



@box87, be aware that single upload class is larger than most of the the entire bbpress core code itself – massive overkill unless you really, really really need it’s extra features?

@louisedade – I found a major caching bug where you are not taking advantage of user meta data that has already been loaded previously in the same execution – this causes 10-30 extra mysql queries for every topic that is displayed depending on how many posts are displayed at once.

Here’s a hacked workaround, though I am not sure it’s a good idea to tap into the user_cache directly. I’d otherwise suggest nicely using bb_get_user() as it checks the cache first but the problem with that is it fetches ALL the data if not in the cache which is overkill. Too bad there isn’t a bb_get_user_meta($id,’metaname’) but oh well – for now replace this top section of code:

function avatarupload_get_avatar($id, $fulluri=1, $force_db=0)
global $bbdb, $user, $bb_user_cache;

if ($force_db == 0 && ($id == $user->ID || !empty($bb_user_cache[$id])) )
if (!empty($user->avatar_file)) {
$a = explode("|", $user->avatar_file);
} else {
if (!empty($bb_user_cache[$id]->avatar_file)) {
$a = explode("|", $bb_user_cache[$id]->avatar_file);
else {return false;}

Drops my topic queries by 20 per page while still functioning correctly in all other cases.

Discovered this problem via bb-benchmark

Skip to toolbar