Bug Conflict with Siropu's Chat

Nicolas

New Member
Joined
Oct 27, 2018
Messages
9
Any idea what could be causing this error?
I'm told it's a conflict with this add-on.
Code:
     LogicException: Macro public:siropu_chat_guest_macros :: username() error: Cannot instantiate XF:User (SV\ReportImprovements\XF\Entity\User) without primary key values src/XF/Mvc/Entity/Manager.php:723 

#0 src/addons/XFA/CustomUsernameIcons/XF/Template/Templater.php(28): XF\Mvc\Entity\Manager->instantiateEntity('XF:User', Array)
#1 [internal function]: XFA\CustomUsernameIcons\XF\Template\Templater->fnUsernameLink(Object(SV\UserActivity\XF\Template\Templater), false, Array, false, Array)
#2 src/XF/Template/Templater.php(922): call_user_func_array(Array, Array)
#3 internal_data/code_cache/templates/l1/s6/public/siropu_chat_guest_macros.php(23): XF\Template\Templater->fn('username_link', Array)
#4 src/XF/Template/Templater.php(701): XF\Template\Templater->{closure}(Object(SV\UserActivity\XF\Template\Templater), Array, Array)
#5 internal_data/code_cache/templates/l1/s6/public/siropu_chat_room_message_helper.php(53): XF\Template\Templater->callMacro('siropu_chat_gue...', 'username', Array, Array)
#6 src/XF/Template/Templater.php(701): XF\Template\Templater->{closure}(Object(SV\UserActivity\XF\Template\Templater), Array, Array)
#7 internal_data/code_cache/templates/l1/s6/public/siropu_chat_room_message_row.php(16): XF\Template\Templater->callMacro('siropu_chat_roo...', 'message_content', Array, Array)
#8 src/XF/Template/Templater.php(1301): XF\Template\Templater->{closure}(Object(SV\UserActivity\XF\Template\Templater), Array)
#9 src/XF/Template/Templater.php(1374): XF\Template\Templater->renderTemplate('siropu_chat_roo...', Array)
#10 internal_data/code_cache/templates/l1/s6/public/siropu_chat_message_list.php(15): XF\Template\Templater->includeTemplate('public:siropu_c...', Array)
#11 src/XF/Template/Templater.php(701): XF\Template\Templater->{closure}(Object(SV\UserActivity\XF\Template\Templater), Array, Array)
#12 internal_data/code_cache/templates/l1/s6/public/siropu_chat.php(534): XF\Template\Templater->callMacro('siropu_chat_mes...', 'room', Array, Array)
#13 src/XF/Template/Templater.php(1301): XF\Template\Templater->{closure}(Object(SV\UserActivity\XF\Template\Templater), Array)
#14 src/XF/Widget/WidgetRenderer.php(62): XF\Template\Templater->renderTemplate('siropu_chat', Array)
#15 src/XF/Widget/WidgetRenderer.php(67): XF\Widget\WidgetRenderer->render()
#16 src/XF/Template/Templater.php(1620): XF\Widget\WidgetRenderer->__toString()
#17 internal_data/code_cache/templates/l1/s6/public/forum_list.php(243): XF\Template\Templater->widgetPosition('siropu_chat_bel...', Array)
#18 src/XF/Template/Templater.php(1301): XF\Template\Templater->{closure}(Object(SV\UserActivity\XF\Template\Templater), Array)
#19 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('forum_list', Array)
#20 src/XF/Mvc/Renderer/Html.php(48): XF\Template\Template->render()
#21 src/XF/Mvc/Dispatcher.php(418): XF\Mvc\Renderer\Html->renderView('XF:Forum\\Listin...', 'public:forum_li...', Array)
#22 src/XF/Mvc/Dispatcher.php(400): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#23 src/XF/Mvc/Dispatcher.php(360): XF\Mvc\Dispatcher->renderReply(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#24 src/XF/Mvc/Dispatcher.php(53): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#25 src/XF/App.php(2177): XF\Mvc\Dispatcher->run()
#26 src/XF.php(390): XF\App->run()
#27 index.php(20): XF::runApp('XF\\Pub\\App')
#28 {main}
 

Nicolas

New Member
Joined
Oct 27, 2018
Messages
9
No, it happens when anybody views the chat room on the index page - the error is generated by logged in users:
Generated by: Nicolas King Apr 14, 2019 at 1:11 PM
 

MtoR

Freaky Coder
Staff member
Joined
Nov 14, 2015
Messages
3,838
Hum odd, please try the following.

Edit the file src/addons/XFA/CustomUsernameIcons/XF/Template/Templater.php.

Search:
PHP:
if (!is_object($user))
{
    $user = \XF::em()->instantiateEntity('XF:User', $user);
}
Replace by:
PHP:
if (!is_object($user))
{
    if (!isset($user['user_id'])
    {
        return $username;
    }

    $user = \XF::em()->instantiateEntity('XF:User', $user);
}
Tell me if that fixes it.
 

Nicolas

New Member
Joined
Oct 27, 2018
Messages
9
Making that edit broke my board:
Code:
An exception occurred: [ParseError] syntax error, unexpected '{' in src/addons/XFA/CustomUsernameIcons/XF/Template/Templater.php on line 27

    Composer\Autoload\includeFile() in src/vendor/composer/ClassLoader.php at line 322
    Composer\Autoload\ClassLoader->loadClass()
    spl_autoload_call()
    class_exists() in src/XF/Extension.php at line 172
    XF\Extension->extendClass() in src/XF/App.php at line 2661
    XF\App->extendClass() in src/XF/App.php at line 1665
    XF\App->setupTemplaterObject() in src/XF/App.php at line 1296
    XF\App->XF\{closure}() in src/XF/Container.php at line 28
    XF\Container->offsetGet() in src/XF/App.php at line 2961
    XF\App->templater() in src/XF/Pub/App.php at line 424
    XF\Pub\App->preRender() in src/XF/Mvc/Dispatcher.php at line 355
    XF\Mvc\Dispatcher->render() in src/XF/Mvc/Dispatcher.php at line 53
    XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2177
    XF\App->run() in src/XF.php at line 390
    XF::runApp() in index.php at line 20
The bracket which is causing the error is marked in red:

if (!is_object($user))
{
if (!isset($user['user_id'])
{
return $username;
}

$user = \XF::em()->instantiateEntity('XF:User', $user);
}
 

MtoR

Freaky Coder
Staff member
Joined
Nov 14, 2015
Messages
3,838
Right:
PHP:
if (!is_object($user))
{
    if (!isset($user['user_id']))
    {
        return $username;
    }

    $user = \XF::em()->instantiateEntity('XF:User', $user);
}
 

Nicolas

New Member
Joined
Oct 27, 2018
Messages
9
I should have been able to notice that missing parenthesis... sorry about that!

Yes, that resolved the error! :)