[FIXED] ErrorException: Template error: Cannot call method canUploadMedia on a non-object (NULL)

barefoot

Member
I'm seeing this error in my Server Error Logs. It seems to be from users who are not logged in trying to add a new album.

Code:
ErrorException: Template error: Cannot call method canUploadMedia on a non-object (NULL) src/XF/Template/Templater.php:927

Generated by: Unknown account Dec 11, 2018 at 3:36 PM

Stack trace

#0 [internal function]: XF\Template\Templater->handleTemplateError(512, 'Cannot call met...', '/home/***/publi...', 927, Array)
#1 src/XF/Template/Templater.php(927): trigger_error('Cannot call met...', 512)
#2 internal_data/code_cache/templates/l1/s1/public/tl_groups_media_album_create.php(34): XF\Template\Templater->method(NULL, 'canUploadMedia', Array)
#3 src/XF/Template/Templater.php(1250): XF\Template\Templater->{closure}(Object(XF\Template\Templater), Array)
#4 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('tl_groups_media...', Array)
#5 src/XF/Mvc/Renderer/Html.php(48): XF\Template\Template->render()
#6 src/XF/Mvc/Dispatcher.php(332): XF\Mvc\Renderer\Html->renderView('XF:Error\\Regist...', 'public:tl_group...', Array)
#7 src/XF/Mvc/Dispatcher.php(303): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#8 src/XF/Mvc/Dispatcher.php(44): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#9 src/XF/App.php(1931): XF\Mvc\Dispatcher->run()
#10 src/XF.php(329): XF\App->run()
#11 index.php(13): XF::runApp('XF\\Pub\\App')
#12 {main}

Request state
   
array(4) {
  ["url"] => string(31) "/media/albums/create?group_id=9"
  ["referrer"] => bool(false)
  ["_GET"] => array(1) {
    ["group_id"] => string(1) "9"
  }
  ["_POST"] => array(0) {
  }
}
How to recreate this error:
I can recreate this error when I am not logged into my forum. I then navigate to a group and click on Media. I then click Add Album and it shows me the input boxes Album title and Album Description (without the upload media icons). I type in the input boxes and then press Save and it throws the error in the server error log.

It seems to me that there is a permissions error here. Guest users should not be able to create albums.

Similar error:
There's a thread on xenforo.com which seems to discuss a similar problem with another plugin: https://xenforo.com/community/threads/template-error-cannot-call-method-isignoring-on-a-non-object-null.153714/
 
Last edited:
Top