- 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.
PHP:
protected function _save()
{
...
$threadLatest = $this->db()->fetchRow("
SELECT *
FROM xf_thread
WHERE thread_id = ?
FOR UPDATE
", $this->thread->thread_id);
// Ensure our thread entity has the latest data to make sure things like reply count are correct
$forceUpdateColumns = [
'first_post_id',
'reply_count',
'last_post_date',
'last_post_id',
'last_post_user_id',
'last_post_username'
];
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.