XF 2.1 Updated to 2.1.8 today: Template error: Method canLike is not callable on the given object

PabloC

Member
Hi,

I updated my Xenforo today, and moved it to PHP 7.4. So far I have over 4.000 error messages like this one (all the same):

ErrorException: Template error: Method canLike is not callable on the given object (XFMG\XF\Entity\Post)
src/XF/Template/Templater.php:994

#0 [internal function]: XF\Template\Templater->handleTemplateError(512, 'Method canLike ...', '/home/gaturro/p...', 994, Array)
#1 src/XF/Template/Templater.php(994): trigger_error('Method canLike ...', 512)
#2 internal_data/code_cache/templates/l3/s1/public/post_macros.php(187): XF\Template\Templater->method(Object(XFMG\XF\Entity\Post), 'canLike', Array)
#3 src/XF/Template/Templater.php(701): XF\Template\Templater->{closure}(Object(XF\Template\Templater), Array, Array)
#4 internal_data/code_cache/templates/l3/s1/public/thread_view.php(611): XF\Template\Templater->callMacro('post_macros', 'post', Array, Array)
#5 src/XF/Template/Templater.php(1315): XF\Template\Templater->{closure}(Object(XF\Template\Templater), Array)
#6 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('thread_view', Array)
#7 src/XF/Mvc/Renderer/Html.php(48): XF\Template\Template->render()
#8 src/XF/Mvc/Dispatcher.php(458): XF\Mvc\Renderer\Html->renderView('XF:Thread\\View', 'public:thread_v...', Array)
#9 src/XF/Mvc/Dispatcher.php(440): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#10 src/XF/Mvc/Dispatcher.php(400): XF\Mvc\Dispatcher->renderReply(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#11 src/XF/Mvc/Dispatcher.php(58): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#12 src/XF/App.php(2184): XF\Mvc\Dispatcher->run()
#13 src/XF.php(391): XF\App->run()
#14 index.php(20): XF::runApp('XF\\Pub\\App')
#15 {main}

Could anyone be so kind as to guide me about where should I look? The language of the forum is Spanish.

Thanks!
 
I found the solution ;)

The cause of this error are outdated templates. I will try to explain what I have done to solve this issue.

After you backup everything, you must go to:

Appearance > Outdated templates

where you will find a list of the outdated templates.

Then, download the latest version of XenForo, but UNCHECK "Download the upgrade package only",
so you donwload all the files, as if you were to install Xenforo for the first time.

Customer account   XenForo.webp

Unzip the files, and go to templates.xml [upload/src/addons/_data/templates.xml]. This files is big, with over 50.000 lines.

Go back to the admin, and open the first of the outdated templates, and copy part of the first or second line, and search templates.xml to find where it starts and where it ends. Copy the new template from templates.xml and replace it on the admin. Do the same with all outdated templates, and the problem will be solved.

It worked for me.
 
Top Bottom