Fixed Avatar forcetype throws error

Affected version
2.0 Beta 6


Well-known member
I was hoping to trick xf:avatar into allowing an array instead of an entity when I ran across this error:
Fatal error:  Method XF\Widget\WidgetRenderer::__toString() must not throw an exception, caught Error: Call to a member function getAvatarUrl() on array in /var/www/clients/client0/web1/web/src/XF/Template/Templater.php on line 0
I was using this template code:
<xf:avatar user="$user" size="xs" forcetype="custom" />

Chris D

XenForo developer
Staff member
If $user is an array (or some other falsey value), rather than a User entity then this will happen.

So it's not supposed to work. That said, we should probably be making that more clear or bailing out sooner with a nicer message (or just falling back to the default avatar regardless).


Well-known member
Yeah, that was kind of my point. I really didn't expect the array to work (although it would be nice). But I didn't expect the error either.


XenForo Developer
Staff member
Fixed now. I think the $forceType switch in use when $user is not an entity is a leftover from some previous assumptions.