Fixed Internal server error on replying to a thread which is hard deleted in the middle of a reply


Well-known member
Affected version
2.2.7 Patch 1
XF\Service\Thread\Replier::_save will throw an internal server error (ErrorException: [E_WARNING] Trying to access array offset on value of type bool) when replying to a thread which has been hard deleted during that reply.

protected function _save()
   $threadLatest = $this->db()->fetchRow("
      SELECT *
      FROM xf_thread
      WHERE thread_id = ?
   ", $this->thread->thread_id);

   // Ensure our thread entity has the latest data to make sure things like reply count are correct
   $forceUpdateColumns = [
   foreach ($forceUpdateColumns AS $forceUpdateColumn)
      $this->thread->setAsSaved($forceUpdateColumn, $threadLatest[$forceUpdateColumn]); <- error here

The thread existed until the _save call, at which point the $threadLatest variable is false. This causes an internal error instead of a useful error message that the thread has gone away.
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.8).

Change log:
When replying to a thread that has been deleted during the reply, throw a clearer error message
There may be a delay before changes are rolled out to the XenForo Community.
Top Bottom