XF 2.1 InvalidArgumentException: Accessed unknown getter 'like_count' on XF:User[1]

giorgino

Well-known member
Hello I get a rid of these errors....

Code:
InvalidArgumentException: Accessed unknown getter 'like_count' on XF:User[1] src/XF/Mvc/Entity/Entity.php:194

Code:
#0 src/XF/Mvc/Entity/Entity.php(106): XF\Mvc\Entity\Entity->get('like_count')
#1 internal_data/code_cache/templates/l4/s5/public/message_macros.php(281): XF\Mvc\Entity\Entity->offsetGet('like_count')
#2 src/XF/Template/Templater.php(694): XF\Template\Templater->{closure}(Object(xenMade\LAU\XF\Template\Templater), Array, Array)
#3 internal_data/code_cache/templates/l4/s5/public/post_macros.php(212): XF\Template\Templater->callMacro('message_macros', 'signature', Array, Array)
#4 src/XF/Template/Templater.php(694): XF\Template\Templater->{closure}(Object(xenMade\LAU\XF\Template\Templater), Array, Array)
#5 internal_data/code_cache/templates/l4/s5/public/thread_view.php(514): XF\Template\Templater->callMacro('post_macros', 'post', Array, Array)
#6 src/XF/Template/Templater.php(1294): XF\Template\Templater->{closure}(Object(xenMade\LAU\XF\Template\Templater), Array)
#7 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('thread_view', Array)
#8 src/XF/Mvc/Renderer/Html.php(48): XF\Template\Template->render()
#9 src/XF/Mvc/Dispatcher.php(418): XF\Mvc\Renderer\Html->renderView('XF:Thread\\View', 'public:thread_v...', Array)
#10 src/XF/Mvc/Dispatcher.php(400): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#11 src/XF/Mvc/Dispatcher.php(360): XF\Mvc\Dispatcher->renderReply(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#12 src/XF/Mvc/Dispatcher.php(53): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#13 src/XF/App.php(2177): XF\Mvc\Dispatcher->run()
#14 src/XF.php(392): XF\App->run()
#15 index.php(20): XF::runApp('XF\\Pub\\App')
#16 {main}


Code:
array(4) {
  ["url"] => string(55) "/community/threads/consiglio-xenforo-vs-vbulletin.1427/"
  ["referrer"] => string(34) "https://www.xfitalia.it/community/"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}

🤔
 
like_count doesn't exist in 2.1.

This is an outdated template -- or more specifically, customizations that are based on 2.0. Normally, this would be caught when dealing with outdated templates, but it's possible you just merged your changes. That doesn't account for core changes that might invalidate your custom code.

You'll need to modify the template to account for XF's changes (the equivalent would now be reaction_score; the template in question with the bad edit is message_macros). If this is from a third-party, you should contact the style author for guidance.
 
This is an outdated template -- or more specifically, customizations that are based on 2.0.
You're right Mike (of course ☺)
This is the line that cause the error.
Do you have any advise to solve this?

Code:
<span class="user-stas">Messaggi: {$user.message_count|number} | Piaciuto: {$user.like_count|number} | Punti: {$user.trophy_points|number} | Utente dal {{ date($user.register_date) }} | Scrivo da {$user.Profile.location}</span>

PHP:
class Callback
{   
    public static function getString($contents, $params)
    {
        $db = \XF::db();
        $result = $db->fetchRow("SELECT * FROM xf_profile_post WHERE profile_user_id = '$params[0]' AND  user_id = '$params[0]'  ORDER BY profile_post_id DESC LIMIT 0,1");
        return isset($result['message']) ? $result['message'] : "";
    }
}
 
Last edited:
Back
Top Bottom