XF 2.3 ErrorException: [E_WARNING] Attempt to read property "thread_id" on null in src/

Abraham54

Well-known member
Licensed customer
My forum had strange faults so I made a new install and imported my forum.
The import went wellbut after finalizing I get this warning:

ErrorException: [E_WARNING] Attempt to read property "thread_id" on null in src/XF/ThreadType/QuestionHandler.php at line 498

  1. XF::handlePhpError() in src/XF/ThreadType/QuestionHandler.php at line 498
  2. XF\ThreadType\QuestionHandler->onThreadRebuildCounters() in src/XF/Entity/Thread.php at line 882
  3. XF\Entity\Thread->rebuildCounters() in src/XF/Job/Thread.php at line 37
  4. XF\Job\Thread->rebuildById() in src/XF/Job/AbstractRebuildJob.php at line 65
  5. XF\Job\AbstractRebuildJob->run() in src/XF/Job/Atomic.php at line 40
  6. XF\Job\Atomic->run() in src/XF/Job/Manager.php at line 275
  7. XF\Job\Manager->runJobInternal() in src/XF/Job/Manager.php at line 205
  8. XF\Job\Manager->runJobEntry() in src/XF/Job/Manager.php at line 121
  9. XF\Job\Manager->runByIds() in src/XF/Admin/Controller/ToolsController.php at line 146
  10. XF\Admin\Controller\ToolsController->actionRunJob() in src/XF/Mvc/Dispatcher.php at line 364
  11. XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 266
  12. XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 121
  13. XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 63
  14. XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2840
  15. XF\App->run() in src/XF.php at line 850
  16. XF::runApp() in admin.php at line 15

  • ErrorException: [E_WARNING] Attempt to read property "thread_id" on null
  • src/XF/ThreadType/QuestionHandler.php:498
  • Gegenereerd door: Abraham545
  • 20 nov 2026 om 12:08
Stack trace
#0 src/XF/ThreadType/QuestionHandler.php(498): XF::handlePhpError(2, '[E_WARNING] Att...', '/home/u46315p56...', 498)
#1 src/XF/Entity/Thread.php(882): XF\ThreadType\QuestionHandler->onThreadRebuildCounters(Object(XF\Entity\Thread))
#2 src/XF/Job/Thread.php(37): XF\Entity\Thread->rebuildCounters()
#3 src/XF/Job/AbstractRebuildJob.php(65): XF\Job\Thread->rebuildById(13984)
#4 src/XF/Job/Atomic.php(40): XF\Job\AbstractRebuildJob->run(8)
#5 src/XF/Job/Manager.php(275): XF\Job\Atomic->run(8)
#6 src/XF/Job/Manager.php(205): XF\Job\Manager->runJobInternal(Array, 8)
#7 src/XF/Job/Manager.php(121): XF\Job\Manager->runJobEntry(Array, 8)
#8 src/XF/Admin/Controller/ToolsController.php(146): XF\Job\Manager->runByIds(Array, 8)
#9 src/XF/Mvc/Dispatcher.php(364): XF\Admin\Controller\ToolsController->actionRunJob(Object(XF\Mvc\ParameterBag))
#10 src/XF/Mvc/Dispatcher.php(266): XF\Mvc\Dispatcher->dispatchClass('XF:Tools', 'RunJob', Object(XF\Mvc\RouteMatch), Object(XF\Admin\Controller\ToolsController), NULL)
#11 src/XF/Mvc/Dispatcher.php(121): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(XF\Admin\Controller\ToolsController), NULL)
#12 src/XF/Mvc/Dispatcher.php(63): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#13 src/XF/App.php(2840): XF\Mvc\Dispatcher->run()
#14 src/XF.php(850): XF\App->run()
#15 admin.php(15): XF::runApp('XF\\Admin\\App')
#16 {main}

Aanvraagstatus​


array(4) {
["url"] => string(24) "/admin.php?tools/run-job"
["referrer"] => string(47) "https://piepcomptest.nl/admin.php?tools/run-job"
["_GET"] => array(1) {
["tools/run-job"] => string(0) ""
}
["_POST"] => array(3) {
["_xfRedirect"] => string(49) "https://piepcomptest.nl/admin.php?import/finalize"
["_xfToken"] => string(8) "********"
["only_ids"] => string(4) "1015"
}
}

How to solve this?
 
My forum had strange faults so I made a new install and imported my forum.
The import went wellbut after finalizing I get this warning:

ErrorException: [E_WARNING] Attempt to read property "thread_id" on null in src/XF/ThreadType/QuestionHandler.php at line 498

  1. XF::handlePhpError() in src/XF/ThreadType/QuestionHandler.php at line 498
  2. XF\ThreadType\QuestionHandler->onThreadRebuildCounters() in src/XF/Entity/Thread.php at line 882
  3. XF\Entity\Thread->rebuildCounters() in src/XF/Job/Thread.php at line 37
  4. XF\Job\Thread->rebuildById() in src/XF/Job/AbstractRebuildJob.php at line 65
  5. XF\Job\AbstractRebuildJob->run() in src/XF/Job/Atomic.php at line 40
  6. XF\Job\Atomic->run() in src/XF/Job/Manager.php at line 275
  7. XF\Job\Manager->runJobInternal() in src/XF/Job/Manager.php at line 205
  8. XF\Job\Manager->runJobEntry() in src/XF/Job/Manager.php at line 121
  9. XF\Job\Manager->runByIds() in src/XF/Admin/Controller/ToolsController.php at line 146
  10. XF\Admin\Controller\ToolsController->actionRunJob() in src/XF/Mvc/Dispatcher.php at line 364
  11. XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 266
  12. XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 121
  13. XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 63
  14. XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2840
  15. XF\App->run() in src/XF.php at line 850
  16. XF::runApp() in admin.php at line 15

  • ErrorException: [E_WARNING] Attempt to read property "thread_id" on null
  • src/XF/ThreadType/QuestionHandler.php:498
  • Gegenereerd door: Abraham545
  • 20 nov 2026 om 12:08
Stack trace
#0 src/XF/ThreadType/QuestionHandler.php(498): XF::handlePhpError(2, '[E_WARNING] Att...', '/home/u46315p56...', 498)
#1 src/XF/Entity/Thread.php(882): XF\ThreadType\QuestionHandler->onThreadRebuildCounters(Object(XF\Entity\Thread))
#2 src/XF/Job/Thread.php(37): XF\Entity\Thread->rebuildCounters()
#3 src/XF/Job/AbstractRebuildJob.php(65): XF\Job\Thread->rebuildById(13984)
#4 src/XF/Job/Atomic.php(40): XF\Job\AbstractRebuildJob->run(8)
#5 src/XF/Job/Manager.php(275): XF\Job\Atomic->run(8)
#6 src/XF/Job/Manager.php(205): XF\Job\Manager->runJobInternal(Array, 8)
#7 src/XF/Job/Manager.php(121): XF\Job\Manager->runJobEntry(Array, 8)
#8 src/XF/Admin/Controller/ToolsController.php(146): XF\Job\Manager->runByIds(Array, 8)
#9 src/XF/Mvc/Dispatcher.php(364): XF\Admin\Controller\ToolsController->actionRunJob(Object(XF\Mvc\ParameterBag))
#10 src/XF/Mvc/Dispatcher.php(266): XF\Mvc\Dispatcher->dispatchClass('XF:Tools', 'RunJob', Object(XF\Mvc\RouteMatch), Object(XF\Admin\Controller\ToolsController), NULL)
#11 src/XF/Mvc/Dispatcher.php(121): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(XF\Admin\Controller\ToolsController), NULL)
#12 src/XF/Mvc/Dispatcher.php(63): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#13 src/XF/App.php(2840): XF\Mvc\Dispatcher->run()
#14 src/XF.php(850): XF\App->run()
#15 admin.php(15): XF::runApp('XF\\Admin\\App')
#16 {main}

Aanvraagstatus​


array(4) {
["url"] => string(24) "/admin.php?tools/run-job"
["referrer"] => string(47) "https://piepcomptest.nl/admin.php?tools/run-job"
["_GET"] => array(1) {
["tools/run-job"] => string(0) ""
}
["_POST"] => array(3) {
["_xfRedirect"] => string(49) "https://piepcomptest.nl/admin.php?import/finalize"
["_xfToken"] => string(8) "********"
["only_ids"] => string(4) "1015"
}
}

How to solve this?
Hi Abraham54,

The rebuild runs fine until it reaches thread 13984. That's a question thread, and its stored data still points to a "solution" post that doesn't exist on the new install (probably deleted on the old forum, or its ID didn't carry over through the import). At line 498, QuestionHandler::onThreadRebuildCounters() loads that post and reads its thread ID without checking that the post was found, so the PHP warning stops the job.

1. Let XenForo clean them up itself. Back up your database and the file first, then in src/XF/ThreadType/QuestionHandler.php change line 498 from:

PHP:
if ($post->thread_id != $thread->thread_id || $post->message_state != 'visible')

to:

PHP:
if (!$post || $post->thread_id != $thread->thread_id || $post->message_state != 'visible')

Then run Admin CP > Tools > Rebuild caches > Rebuild threads. With that check in place, a missing solution post is handled like a solution sitting in the wrong thread: XenForo removes the "solution" mark from the thread and the rebuild goes through, for 13984 and any other thread in the same state.

2. Put the original file back once the rebuild has finished. The broken references are gone by then, so the original line won't hit a missing post anymore. Restoring it also keeps the File health check clean (and the next upgrade would overwrite it anyway).

The only thing you lose is the "solution" mark on those threads. If one of them really matters, you can mark the right answer again by hand.

This one is worth a report in the Bugs forum too: the core should check for a missing post there, like it already does for a solution in the wrong thread.
 
Back
Top Bottom