Fixed Inconsistent behaviour between XF\Pub\View\Like\Like view class & fnLikes template function

Xon

Well-known member
Affected version
2.0.11
The ajax 'like' click will return nothing, but reloading the page says "1 person/x people"

fnLikes natively handles if $count has a value but $likes is empty.

But XF\Pub\View\Like\Like does this check;
PHP:
if ($count && $likes)
{
   $templater = $this->renderer->getTemplater();
   $html = $templater->fn('likes', [$count, $likes, $isLiked, $listUrl]);
}
else
{
   $html = '';
}

Where as fnLikes does this;
PHP:
$count = intval($count);
if ($count <= 0)
{
   return '';
}

if (!$users || !is_array($users))
{
   $phrase = ($count > 1 ? 'likes.x_people' : 'likes.1_person');
   return $this->renderTemplate('public:like_list_row', [
      'url' => $url,
      'likes' => \XF::phrase($phrase, ['likes' => $this->language->numberFormat($count)])
   ]);
}
 
Thank you for reporting this issue. It has now been resolved and we are aiming to include it in a future XF release (2.1.0 RC2).

Change log:
Only check for a $count in the like view for determining if we should display something, for consistency with standard loading.
Any changes made as a result of this issue being resolved may not be rolled out here until later.
 
Worth clarifying that this is actually fixed in the 2.0 branch, though the 2.1 release may will supersede that (hence the listed fixed version). 2.1 reactions don't appear to have the equivalent issue.
 
Back
Top Bottom