• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Fixed Avatar forcetype throws error

Affected version
2.0 Beta 6

Snog

Well-known member
#1
I was hoping to trick xf:avatar into allowing an array instead of an entity when I ran across this error:
Code:
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:
Code:
<xf:avatar user="$user" size="xs" forcetype="custom" />
 

Chris D

XenForo developer
Staff member
#2
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).
 

Snog

Well-known member
#3
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.
 

Kier

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