Fix a bug where thread owners Avatar was used if post owner
did not have one. This is due to behavior in HTML::Template with global_vars=1. If a loop variable is undef, then the global will be used instead. Using empty string '' is a better solution. '' and undef are both false, so template conditionals will not be changed.
This commit is contained in:
parent
32346771c6
commit
36873f8479
2 changed files with 4 additions and 3 deletions
|
|
@ -317,14 +317,14 @@ Returns a URL to the owner's avatar.
|
|||
|
||||
sub getAvatarUrl {
|
||||
my $self = shift;
|
||||
my $avatarUrl;
|
||||
my $parent = $self->getThread->getParent;
|
||||
return undef unless $parent;
|
||||
return $avatarUrl unless $parent->getValue("avatarsEnabled");
|
||||
return '' unless $parent and $parent->getValue("avatarsEnabled");
|
||||
my $user = WebGUI::User->new($self->session, $self->get('ownerUserId'));
|
||||
#Get avatar field, storage Id.
|
||||
my $storageId = $user->profileField("avatar");
|
||||
return '' unless $storageId;
|
||||
my $avatar = WebGUI::Storage::Image->get($self->session,$storageId);
|
||||
my $avatarUrl = '';
|
||||
if ($avatar) {
|
||||
#Get url from storage object.
|
||||
foreach my $imageName (@{$avatar->getFiles}) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue