Fixed Error: Macro public:post_article_macros :: article_preview() error: Call to a member function filter() on null

loulou

Member
Affected version
2.2.2
Code:
Error: Macro public:post_article_macros :: article_preview() error: Call to a member function filter() on null src/XF/Entity/Thread.php:659


Code:
Stack trace
#0 src/XF/Mvc/Entity/Entity.php(157): XF\Entity\Thread->getCoverImage()
#1 src/XF/Mvc/Entity/Entity.php(115): XF\Mvc\Entity\Entity->get('cover_image')
#2 /data/tsat/data/internal_data/internal_data/code_cache/templates/l4/s18/public/post_article_macros.php(493): XF\Mvc\Entity\Entity->offsetGet('cover_image')
#3 src/XF/Template/Templater.php(799): XF\Template\Templater->{closure}(Object(SV\StandardLib\XF\Template\Templater), Array, Object(XF\Template\ExtensionSet))
#4 /data/tsat/data/internal_data/internal_data/code_cache/templates/l4/s18/public/forum_view_type_article.php(153): XF\Template\Templater->callMacro('post_article_ma...', 'article_preview', Array, Array)
#5 src/XF/Template/Templater.php(799): XF\Template\Templater->{closure}(Object(SV\StandardLib\XF\Template\Templater), Array, NULL)
#6 /data/tsat/data/internal_data/internal_data/code_cache/templates/l4/s18/public/forum_view_type_article.php(54): XF\Template\Templater->callMacro('forum_view_type...', 'article_helper', Array, Array)
#7 src/XF/Template/Templater.php(962): XF\Template\Templater->{closure}(Object(SV\StandardLib\XF\Template\Templater), Array, Object(XF\Template\ExtensionSet))
#8 src/XF/Template/Templater.php(898): XF\Template\Templater->renderExtensionInternal('thread_list', Array, Array, Object(XF\Template\ExtensionSet))
#9 /data/tsat/data/internal_data/internal_data/code_cache/templates/l4/s18/public/forum_view.php(583): XF\Template\Templater->renderExtension('thread_list', Array, Object(XF\Template\ExtensionSet))
#10 src/XF/Template/Templater.php(1626): XF\Template\Templater->{closure}(Object(SV\StandardLib\XF\Template\Templater), Array, Object(XF\Template\ExtensionSet))
#11 src/XF/Template/Templater.php(1617): XF\Template\Templater->renderTemplate('forum_view', Array, true, Object(XF\Template\ExtensionSet))
#12 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('forum_view_type...', 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\\ViewTy...', 'public:forum_vi...', 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(2300): XF\Mvc\Dispatcher->run()
#19 src/XF.php(488): XF\App->run()
#20 index.php(20): XF::runApp('XF\\Pub\\App')
#21 {main}
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.3).

Change log:
Prevent an error if a thread shown in an article preview forum is missing the first post relationship.
There may be a delay before changes are rolled out to the XenForo Community.
 
It's worth mentioning that this is a generally unexpected situation, though I have prevented this error. You'd get an error trying to view the article that triggered that (and that error is expected/intentional).

This is specific to the case where we don't have a first_post_id stored for the thread. This can happen during an import before the rebuilds complete (which is why we don't consider the import complete until those rebuilds are done). Otherwise, it should only happen if you have a thread record with no posts, which--outside of redirects--isn't something that should ever happen in XF. We already don't display redirects in article preview forums for this reason. A thread rebuild should resolve this problem if the first_post_id value ends up incorrect for some reason; if that doesn't sort it, the invalid thread should be (permanently) deleted.
 
Back
Top Bottom