Fixed ErrorException: Template error: Template public:like_item_discussion is unknown

Anthony Parsons

Well-known member
Affected version
2.0.7
Getting error on dev install.

Code:
Server error log
[LIST]
[*]ErrorException: Template error: Template public:like_item_discussion is unknown
[*] 
[*]src/XF/Template/Templater.php:583
[*]Generated by: somerandomguy
[*] 
[*]Jul 3, 2018 at 10:36 PM
[/LIST]
Stack trace
#0 [internal function]: XF\Template\Templater->handleTemplateError(512, 'Template public...', '/var/www/myptsd...', 583, Array)
#1 src/XF/Template/Templater.php(583): trigger_error('Template public...', 512)
#2 src/XF/Template/Templater.php(538): XF\Template\Templater->getTemplateData('public', 'like_item_discu...')
#3 src/XF/Template/Templater.php(1248): XF\Template\Templater->getTemplateCode('public', 'like_item_discu...')
#4 src/XF/Like/AbstractHandler.php(66): XF\Template\Templater->renderTemplate('like_item_discu...', Array)
#5 src/XF/Entity/LikedContent.php(65): XF\Like\AbstractHandler->render(Object(XF\Entity\LikedContent))
#6 [internal function]: XF\Entity\LikedContent->render()
#7 src/XF/Template/Templater.php(939): call_user_func_array(Array, Array)
#8 internal_data/code_cache/templates/l1/s85/public/sv_ue_account_likes_given.php(31): XF\Template\Templater->method(Object(XF\Entity\LikedContent), 'render', Array)
#9 src/XF/Template/Templater.php(1249): XF\Template\Templater->{closure}(Object(KL\UserImprovements\Template\Templater), Array)
#10 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('sv_ue_account_l...', Array)
#11 src/XF/Mvc/Renderer/Html.php(48): XF\Template\Template->render()
#12 src/XF/Mvc/Dispatcher.php(332): XF\Mvc\Renderer\Html->renderView('XF:Account\\Like...', 'public:sv_ue_ac...', Array)
#13 src/XF/Mvc/Dispatcher.php(303): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#14 src/XF/Mvc/Dispatcher.php(44): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#15 src/XF/App.php(1931): XF\Mvc\Dispatcher->run()
#16 src/XF.php(328): XF\App->run()
#17 index.php(13): XF::runApp('XF\\Pub\\App')
#18 {main}

Request state
array(4) {
  ["url"] => string(20) "/account/likes-given"
  ["referrer"] => string(39) "https://www.ptsdnews.com/account/alerts"
  ["_GET"] => array(1) {
    ["/account/likes-given"] => string(0) ""
  }
  ["_POST"] => array(0) {
  }
}
 
ErrorException: Template error: Template public:like_item_discussion is unknown
'like_item_discussion' is not a core XenForo template. The only like_item_content_type templates that are included with XF 2.0.x are:
  • like_item_conversation_message
  • like_item_post
  • like_item_profile_post
  • like_item_profile_post_comment
There are no Public, Email or Admin templates in XenForo 2.0.x that have the term 'discussion' in the template name.
 
Ok... I have posted this onto User Essentials add-on for @Xon, as I think this might be their add-on causing it as the file sv_ue_account_likes_given.php listed is user essentials add-on.
 
My User Essentials add-on doesn't add a like_item_discussion template or related like (content type: item, action: discussion), this is showing up because you have something adding a 'Like' without actually adding the required template. sv_ue_account_likes_given.php is being shown because it is showing given likes.

This is basically another add-on has not fully implemented a Like handling correctly.
 
It turns out it's my add-on. It took me a while to find what was causing it because I couldn't duplicate it on my development server. It will be fixed on Monday.

And I'm still curious where the likes-given is coming from?
 
I believe this is fixed in XF 2.0.10 in terms of having a way to avoid rendering a like or alert template when the template does not exist.

@Xon, you may need to add support for this in your add-on, it looks something like this:
PHP:
$likes = $likes->filter(function(\XF\Entity\LikedContent $like)
{
   return $like->canView() && $like->isLikeRenderable();
});
That would replace the call to:
PHP:
$likes = $likes->filterViewable();
 
Top Bottom