XF 2.2 Key 'post_date' doesn't exist in table 'xf_profile_post'

SurferJon

Active member
Hi, this bug started happening a few days ago. I think after I upgraded from 2.1 to 2.2. There's thousands of pages of errors for it. :x

Any ideas?

  • XF\Db\InvalidQueryException: Error rendering widget: MySQL statement prepare error [1176]: Key 'post_date' doesn't exist in table 'xf_profile_post'
  • src/XF/Db/AbstractStatement.php:228

  • Generated by: Unknown account
  • Jul 14, 2021 at 5:02 PM


Stack trace​


SELECT xf_profile_post., xf_user_ProfileUser_1., xf_user_privacy_Privacy_2., xf_user_User_3.
FROM xf_profile_post USE INDEX (post_date)
LEFT JOIN xf_user AS xf_user_ProfileUser_1 ON (xf_user_ProfileUser_1.user_id = xf_profile_post.profile_user_id)
LEFT JOIN xf_user_privacy AS xf_user_privacy_Privacy_2 ON (xf_user_privacy_Privacy_2.user_id = xf_user_ProfileUser_1.user_id)
LEFT JOIN xf_user AS xf_user_User_3 ON (xf_user_User_3.user_id = xf_profile_post.user_id)
WHERE (xf_profile_post.message_state = 'visible')
ORDER BY xf_profile_post.post_date DESC

LIMIT 10
------------

#0 src/XF/Db/Mysqli/Statement.php(196): XF\Db\AbstractStatement->getException('MySQL statement...', 1176, '42000')
#1 src/XF/Db/Mysqli/Statement.php(39): XF\Db\Mysqli\Statement->getException('MySQL statement...', 1176, '42000')
#2 src/XF/Db/Mysqli/Statement.php(54): XF\Db\Mysqli\Statement->prepare()
#3 src/XF/Db/AbstractAdapter.php(94): XF\Db\Mysqli\Statement->execute()
#4 src/XF/Mvc/Entity/Finder.php(1379): XF\Db\AbstractAdapter->query('
SELECT `xf_...')
#5 src/XF/Widget/NewProfilePosts.php(77): XF\Mvc\Entity\Finder->fetch()
#6 internal_data/code_cache/widgets/_9_forum_overview_new_profile_posts.php(5): XF\Widget\NewProfilePosts->render()
#7 src/XF/Template/Templater.php(7498): XF\SubContainer\Widget->{closure}(Object(Iconify\Iconify\Template\Templater), Array, Array)
#8 src/XF/SubContainer/Widget.php(168): XF\Template\Templater->renderWidgetClosure(Object(Closure), Array)
#9 src/XF/Template/Templater.php(1919): XF\SubContainer\Widget->getCompiledWidget(Array, Array)
#10 internal_data/code_cache/templates/l1/s3/public/forum_list.php(216): XF\Template\Templater->widgetPosition('forum_list_side...', Array)
#11 src/XF/Template/Templater.php(1644): XF\Template\Templater->{closure}(Object(Iconify\Iconify\Template\Templater), Array, NULL)
#12 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('forum_list', Array)
#13 src/XF/Mvc/Renderer/Html.php(48): XF\Template\Template->render()
#14 src/XF/Mvc/Dispatcher.php(458): XF\Mvc\Renderer\Html->renderView('XF:Forum\\Listin...', 'public:forum_li...', Array)
#15 src/XF/Mvc/Dispatcher.php(440): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#16 src/XF/Mvc/Dispatcher.php(400): XF\Mvc\Dispatcher->renderReply(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#17 src/XF/Mvc/Dispatcher.php(58): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#18 src/XF/App.php(2344): XF\Mvc\Dispatcher->run()
#19 src/XF.php(512): XF\App->run()
#20 index.php(20): XF::runApp('XF\\Pub\\App')
#21 {main}


Request state​


array(4) {
["url"] => string(8) "/forums/"
["referrer"] => string(26) "https://www.pokebeach.com/"
["_GET"] => array(0) {
}
["_POST"] => array(0) {
}
}
 
Solution
It looks like you're missing an index that is expected to be there. I'm pretty sure this index has been present since the very early versions of XF so I'm not totally sure why you don't have it. However, to add it, you should be able to run this query:

Code:
ALTER TABLE xf_profile_post ADD INDEX (post_date);

That should stop the errors (and also make this query significantly more efficient).

Mike

XenForo developer
Staff member
It looks like you're missing an index that is expected to be there. I'm pretty sure this index has been present since the very early versions of XF so I'm not totally sure why you don't have it. However, to add it, you should be able to run this query:

Code:
ALTER TABLE xf_profile_post ADD INDEX (post_date);

That should stop the errors (and also make this query significantly more efficient).
 
Solution
Top