Not a bug Poll thread type without a poll

Andy.N

Well-known member
Affected version
2.2.15
Got this error from a thread without a poll. When I went to change thread type, it shown as currently a poll. After changing to discussion type, the error still persists.

Server error log TypeError: Extension public:thread_view :: structured_data() error: XF\ThreadType\AbstractHandler::isPostVotingSupported(): Argument #2 ($post) must be of type XF\Entity\Post, null given, called in /home/nginx/domains/x.com/public/src/XF/ThreadType/AbstractHandler.php on line 321 src/XF/ThreadType/AbstractHandler.php:506 Generated by: 1/31/24 at 6:24 PM [HEADING=2]Stack trace[/HEADING] #0 src/XF/ThreadType/AbstractHandler.php(321): XF\ThreadType\AbstractHandler->isPostVotingSupported(Object(TickTackk\ChangeContentOwner\XF\Entity\Thread), NULL) #1 src/XF/Entity/Thread.php(929): XF\ThreadType\AbstractHandler->getLdStructuredData(Object(TickTackk\ChangeContentOwner\XF\Entity\Thread), Object(TickTackk\ChangeContentOwner\XF\Entity\Post), 1, Array) #2 src/XF/Template/Templater.php(1195): XF\Entity\Thread->getLdStructuredData(Object(TickTackk\ChangeContentOwner\XF\Entity\Post), 1, Array) #3 internal_data/code_cache/templates/l1/s33/public/thread_view.php(13): XF\Template\Templater->method(Object(TickTackk\ChangeContentOwner\XF\Entity\Thread), 'getLdStructured...', Array) #4 src/XF/Template/Templater.php(991): XF\Template\Templater->{closure}(Object(OzzModz\VerificationBadges\XF\Template\Templater), Array, Object(XF\Template\ExtensionSet)) #5 src/XF/Template/Templater.php(927): XF\Template\Templater->renderExtensionInternal('structured_data', Array, Array, Object(XF\Template\ExtensionSet)) #6 internal_data/code_cache/templates/l1/s33/public/thread_view.php(640): XF\Template\Templater->renderExtension('structured_data', Array, Object(XF\Template\ExtensionSet)) #7 src/XF/Template/Templater.php(1655): XF\Template\Templater->{closure}(Object(OzzModz\VerificationBadges\XF\Template\Templater), Array, Object(XF\Template\ExtensionSet)) #8 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('thread_view', Array) #9 src/XF/Mvc/Renderer/Html.php(50): XF\Template\Template->render() #10 src/XF/Mvc/Dispatcher.php(460): XF\Mvc\Renderer\Html->renderView('XF:Thread\\View', 'public:thread_v...', Array) #11 src/XF/Mvc/Dispatcher.php(442): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View)) #12 src/XF/Mvc/Dispatcher.php(402): XF\Mvc\Dispatcher->renderReply(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View)) #13 src/XF/Mvc/Dispatcher.php(60): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html') #14 src/XF/App.php(2487): XF\Mvc\Dispatcher->run() #15 src/XF.php(524): XF\App->run() #16 index.php(20): XF::runApp('XF\\Pub\\App') #17 {main}
[LIST] [*]ErrorException: Template error: [E_WARNING] Attempt to read property "message" on null [*]src/XF/ThreadType/AbstractHandler.php:314 [*]Generated by [*]1/31/24 at 6:29 PM [/LIST] [HEADING=2]Stack trace[/HEADING] #0 src/XF/ThreadType/AbstractHandler.php(314): XF\Template\Templater->handleTemplateError(2, '[E_WARNING] Att...', '/home/nginx/dom...', 314) #1 src/XF/Entity/Thread.php(929): XF\ThreadType\AbstractHandler->getLdStructuredData(Object(TickTackk\ChangeContentOwner\XF\Entity\Thread), Object(TickTackk\ChangeContentOwner\XF\Entity\Post), 1, Array) #2 src/XF/Template/Templater.php(1195): XF\Entity\Thread->getLdStructuredData(Object(TickTackk\ChangeContentOwner\XF\Entity\Post), 1, Array) #3 internal_data/code_cache/templates/l1/s33/public/thread_view.php(13): XF\Template\Templater->method(Object(TickTackk\ChangeContentOwner\XF\Entity\Thread), 'getLdStructured...', Array) #4 src/XF/Template/Templater.php(991): XF\Template\Templater->{closure}(Object(OzzModz\VerificationBadges\XF\Template\Templater), Array, Object(XF\Template\ExtensionSet)) #5 src/XF/Template/Templater.php(927): XF\Template\Templater->renderExtensionInternal('structured_data', Array, Array, Object(XF\Template\ExtensionSet)) #6 internal_data/code_cache/templates/l1/s33/public/thread_view.php(640): XF\Template\Templater->renderExtension('structured_data', Array, Object(XF\Template\ExtensionSet)) #7 src/XF/Template/Templater.php(1655): XF\Template\Templater->{closure}(Object(OzzModz\VerificationBadges\XF\Template\Templater), Array, Object(XF\Template\ExtensionSet)) #8 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('thread_view', Array) #9 src/XF/Mvc/Renderer/Html.php(50): XF\Template\Template->render() #10 src/XF/Mvc/Dispatcher.php(460): XF\Mvc\Renderer\Html->renderView('XF:Thread\\View', 'public:thread_v...', Array) #11 src/XF/Mvc/Dispatcher.php(442): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View)) #12 src/XF/Mvc/Dispatcher.php(402): XF\Mvc\Dispatcher->renderReply(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View)) #13 src/XF/Mvc/Dispatcher.php(60): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html') #14 src/XF/App.php(2487): XF\Mvc\Dispatcher->run() #15 src/XF.php(524): XF\App->run() #16 index.php(20): XF::runApp('XF\\Pub\\App') #17 {main}
 
Thank you. This has been resolved with your tip.
Changed the thread type to discussion then rebuild thread data to clear this up. No more error.
 
Will leave this open to see if we get further reports, but it's not immediately clear how this would occur short of an add-on or direct database manipulation.
 
We also encountered this message after we upgraded to 2.2.15. It appears to have occurred in cases where the first post of a thread was deleted. It looks like all the threads that have this issue had a first post date from when we used to run on vBulletin (since deleting the first post deletes the thread in Xenforo).
 
We've seen another instance of this today. It seems to be exclusively manifesting with older threads, likely imported from other software, that have missing first_post_id references.

We could silence errors like this simply enough but I'm of the opinion that we should let them be surfaced as it is reasonable for us to expect that every thread should have a first_post_id and where that isn't the case it probably should be fixed. The fix in that case is to rebuild threads which seems to have worked in all cases so far.
 
I'm seeing this now. Looking into this thread here, seems to be the same use case where post1 is deleted.

Post 1 was deleted due to a user ban/data removal request, and there is no deleted info so it very well may have been done on vb as the above user mentions.

1715180607882.webp

  • TypeError: Extension public:thread_view :: structured_data() error: XF\ThreadType\AbstractHandler::isPostVotingSupported(): Argument #2 ($post) must be of type XF\Entity\Post, null given, called in /home/nginx/domains/xxxxxxxxxx.com/public/src/XF/ThreadType/AbstractHandler.php on line 321
  • src/XF/ThreadType/AbstractHandler.php:506
  • ErrorException: Template error: [E_WARNING] Attempt to read property "last_edit_date" on null
  • src/XF/ThreadType/AbstractHandler.php:306

  • ErrorException: Template error: [E_WARNING] Attempt to read property "message" on null
  • src/XF/ThreadType/AbstractHandler.php:314

Is there a way to just rebuild one thread ID? I really don't want to go through the entire process for an 18 year old thread that has had 1 random hit to it.
 
Is there a way to just rebuild one thread ID?
I'm not actually sure. I would expect if you undeleted the deleted first post and deleted it again then that might sort it.

But otherwise, no, just run the rebuild. You don't need to rebuild post positions (which is the one that takes a huge amount of time). And running it from the CLI is also an option.
 
Rebuilt, and it doesn't seem to be logging any more. So, it's a fix.

But, stewing on this in my head-- there is absolutely NO way i haven't rebuilt threads, ever, in the 10+ years i've been on XF. Why is this surfacing now? In fact, I know i've run it multiple times when i switched to mariadb and when i deleted a bunch of old rss threads.
 
Yeah that isn't sitting quite right with me either. Most of the cases we've seen so far have been old content where posts were deleted before being imported from, say, vBulletin to XF. The vB to XF importer itself should do a Thread rebuild.

So I am beginning to wonder whether you guys share something in common whereby something maybe recent has surfaced this? Some sort of add-on or something that deletes content or similar that is doing something unexpected?

You mentioned a user deletion request, do you run anything special in XF from an add-on to help with this?
 
It's a manual process, all through xf ui. I ban, anonymize the userid, and then soft-delete key posts (eg, PII data in the thread, email, etc)

I've updated a few addons recently, but nothing related to post management. s9 media sites is the most recent update i did.

This particular thread, that user was just banned and that particular post was removed because it was vulgar. And likely this happened on IPB or VB (I was on ipb before vb before xf)

I DO recall seeing this particular thread in my error logs YEARS ago and i did nothing with it, so perhaps it's not as new as we are thinking.
 
Back
Top Bottom