Not a bug An exception occurred: [TypeError] Argument 1 passed

CoZmicShReddeR

Well-known member
Affected version
v2.0.2
Been getting these random white screen errors visiting posts on my website.

Code:
An exception occurred: [TypeError] Argument 1 passed to XF\Entity\User::canStartConversationWith() must be an instance of XF\Entity\User, null given in src\XF\Entity\User.php on line 830

XF\Entity\User->canStartConversationWith()
call_user_func_array() in src/XF/Template/Templater.php at line 936
XF\Template\Templater->method() in internal_data/code_cache/templates/l1/s50/public/message_macros.php at line 99
XF\Template\Templater->{closure}() in src/XF/Template/Templater.php at line 659
XF\Template\Templater->callMacro() in internal_data/code_cache/templates/l1/s50/public/post_macros.php at line 39
XF\Template\Templater->{closure}() in src/XF/Template/Templater.php at line 659
XF\Template\Templater->callMacro() in internal_data/code_cache/templates/l1/s50/public/thread_view.php at line 760
XF\Template\Templater->{closure}() in src/XF/Template/Templater.php at line 1246
XF\Template\Templater->renderTemplate() in src/XF/Template/Template.php at line 24
XF\Template\Template->render() in src/XF/Mvc/Renderer/Html.php at line 48
XF\Mvc\Renderer\Html->renderView() in src/XF/Mvc/Dispatcher.php at line 332
XF\Mvc\Dispatcher->renderView() in src/XF/Mvc/Dispatcher.php at line 303
XF\Mvc\Dispatcher->render() in src/XF/Mvc/Dispatcher.php at line 44
XF\Mvc\Dispatcher->run() in src/XF/App.php at line 1889
XF\App->run() in src/XF.php at line 328
XF::runApp() in index.php at line 13
 
This appears to be a bug with a template modification (calling canStartConversationWith without checking that it actually has a user).
 
According to this Google Cache:
https://webcache.googleusercontent....iment.634/post-8093+&cd=1&hl=en&ct=clnk&gl=uk

The last post in that thread is a Guest. That ties in exactly with what Mike suggested about calling that function without having a valid user record.

So if the code is something like:
HTML:
<xf:if is="$xf.visitor.canStartConversationWith($user)">
It would need to be changed to something like:
HTML:
<xf:if is="$user.user_id AND $xf.visitor.canStartConversationWith($user)">
 
I really wasn't disagreeing with him I just don't exactly know what you guys are talking about all the time... ;)

So I am still guessing from my limited knowledge with this is that the thread has no one set as the author as to referring the $user.user_id so I would have to possibly add a user through the database as the author?
 
To simplify it, it all boils down to who or what added that code. It's not XF code so it has either been added by you or your style or an add-on. Once you've tracked that down, it's best to either ask whoever added the code, or if it was yourself, post the code that you added in a new thread in the Styling & customizations forum and we'll go from there.
 
Top Bottom