XF 2.3 Template Errors

BobHarbison

Active member
I get these errors daily. I know the obvious, it's a template issue. But I don't have the first clue on how to find and troubleshoot this?

  • ErrorException: Template error: [E_USER_WARNING] Method canViewMedia is not callable on the given object (XF\Entity\User)
  • src/XF/Template/Templater.php:1277
  • Generated by: Unknown account
  • Feb 11, 2026 at 6:26 PM
 
I get these errors daily. I know the obvious, it's a template issue. But I don't have the first clue on how to find and troubleshoot this?

  • ErrorException: Template error: [E_USER_WARNING] Method canViewMedia is not callable on the given object (XF\Entity\User)
  • src/XF/Template/Templater.php:1277
  • Generated by: Unknown account
  • Feb 11, 2026 at 6:26 PM
What is the full Server error log?
 
What is the full Server error log?
  • ErrorException: Template error: [E_USER_WARNING] Method canViewMedia is not callable on the given object (XF\Entity\User)
  • src/XF/Template/Templater.php:1277
  • Generated by: Unknown account
  • Feb 11, 2026 at 6:26 PM

Stack trace​

#0 [internal function]: XF\Template\Templater->handleTemplateError(512, '[E_USER_WARNING...', '/home/railroadf...', 1277)
#1 src/XF/Template/Templater.php(1277): trigger_error('Method canViewM...', 512)
#2 internal_data/code_cache/navigation_cache.php(358): XF\Template\Templater->method(Object(XF\Entity\User), 'canViewMedia', Array)
#3 src/XF/Template/Templater.php(8150): XF\Pub\App->{closure}(Object(XF\Template\Templater), 'forums', Array)
#4 src/XF/Pub/App.php(634): XF\Template\Templater->renderNavigationClosure(Object(Closure), 'forums', Array)
#5 src/XF/Pub/App.php(585): XF\Pub\App->getNavigation(Array, 'forums')
#6 src/XF/App.php(2573): XF\Pub\App->renderPageHtml('

...', Array, Object(XF\Mvc\Reply\View), Object(XF\Mvc\Renderer\Html))
#7 src/XF/Mvc/Dispatcher.php(414): XF\App->renderPage('

...', Object(XF\Mvc\Reply\View), Object(XF\Mvc\Renderer\Html))
#8 src/XF/Mvc/Dispatcher.php(66): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#9 src/XF/App.php(2826): XF\Mvc\Dispatcher->run()
#10 src/XF.php(806): XF\App->run()
#11 index.php(23): XF::runApp('XF\\Pub\\App')
#12 {main}

Request state​

array(4) {
["url"] => string(45) "/forum/index.php?content=thread&user_id=13708"
["referrer"] => bool(false)
["_GET"] => array(2) {
["content"] => string(6) "thread"
["user_id"] => string(5) "13708"
}
["_POST"] => array(0) {
}
}
 
  • ErrorException: Template error: [E_USER_WARNING] Method canViewMedia is not callable on the given object (XF\Entity\User)
  • src/XF/Template/Templater.php:1277
  • Generated by: Unknown account
  • Feb 11, 2026 at 6:26 PM

Stack trace​

#0 [internal function]: XF\Template\Templater->handleTemplateError(512, '[E_USER_WARNING...', '/home/railroadf...', 1277)
#1 src/XF/Template/Templater.php(1277): trigger_error('Method canViewM...', 512)
#2 internal_data/code_cache/navigation_cache.php(358): XF\Template\Templater->method(Object(XF\Entity\User), 'canViewMedia', Array)
#3 src/XF/Template/Templater.php(8150): XF\Pub\App->{closure}(Object(XF\Template\Templater), 'forums', Array)
#4 src/XF/Pub/App.php(634): XF\Template\Templater->renderNavigationClosure(Object(Closure), 'forums', Array)
#5 src/XF/Pub/App.php(585): XF\Pub\App->getNavigation(Array, 'forums')
#6 src/XF/App.php(2573): XF\Pub\App->renderPageHtml('

...', Array, Object(XF\Mvc\Reply\View), Object(XF\Mvc\Renderer\Html))
#7 src/XF/Mvc/Dispatcher.php(414): XF\App->renderPage('

...', Object(XF\Mvc\Reply\View), Object(XF\Mvc\Renderer\Html))
#8 src/XF/Mvc/Dispatcher.php(66): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#9 src/XF/App.php(2826): XF\Mvc\Dispatcher->run()
#10 src/XF.php(806): XF\App->run()
#11 index.php(23): XF::runApp('XF\\Pub\\App')
#12 {main}

Request state​

array(4) {
["url"] => string(45) "/forum/index.php?content=thread&user_id=13708"
["referrer"] => bool(false)
["_GET"] => array(2) {
["content"] => string(6) "thread"
["user_id"] => string(5) "13708"
}
["_POST"] => array(0) {
}
}
The error is happening because your site is trying to run a check called canViewMedia on a user, but that method doesn't actually exist in the core XenForo code. It’s usually added by the XenForo Media Gallery add-on. Since the code can't find the method, it's throwing a warning and breaking the page load.

Why now?
According to the stack trace, this is specifically coming from your Public Navigation (the tabs at the top of your site). This usually happens if:

The Media Gallery add-on was disabled or uninstalled, but a navigation link is still trying to check for it.

A custom navigation tab was added with a "Display Condition" that isn't wrapped in a safety check.

How to fix it
Check Navigation: Go to Setup > Public Navigation in your Admin CP.

Find the Culprit: Look for any "Media" or custom gallery tabs.

Fix the Condition: Look at the "Display condition" box. If it says $xf.visitor.canViewMedia(), swap it to this safer version: $xf.visitor.hasPermission('xengallery', 'view')

Save and Refresh: That should clear the error immediately.

If you just disabled the Media Gallery add-on, simply disabling that navigation link should also do the trick.
 
Fix the Condition: Look at the "Display condition" box. If it says $xf.visitor.canViewMedia(), swap it to this safer version: $xf.visitor.hasPermission('xengallery', 'view')

I strongly suspect that's the problem, since it only throws on fairly rare occasion. I'll dig into it and see what I can find, thank you.
 
Back
Top Bottom