Fixed Undeleted question thread with a deleted first post is inaccessible by visitors


Active member
Affected version
  • Open a question thread.
  • Make 2 more posts. Now we have 3 posts including the first post.
  • Delete second post.
  • Merge first post into deleted post.
  • Now try to access that thread with a user or a visitor account and get this error:

InvalidArgumentException: First post (1311) in thread 791 could not be pinned in src\XF\ThreadViewData.php at line 94
  1. XF\ThreadViewData->pinFirstPost() in src\XF\Pub\Controller\Thread.php at line 114
  2. XF\Pub\Controller\Thread->actionIndex() in src\addons\XFMG\XF\Pub\Controller\Thread.php at line 11
  3. XFMG\XF\Pub\Controller\Thread->actionIndex() in src\XF\Mvc\Dispatcher.php at line 350
  4. XF\Mvc\Dispatcher->dispatchClass() in src\XF\Mvc\Dispatcher.php at line 257
  5. XF\Mvc\Dispatcher->dispatchFromMatch() in src\XF\Mvc\Dispatcher.php at line 113
  6. XF\Mvc\Dispatcher->dispatchLoop() in src\XF\Mvc\Dispatcher.php at line 55
  7. XF\Mvc\Dispatcher->run() in src\XF\App.php at line 2300
  8. XF\App->run() in src\XF.php at line 464
  9. XF::runApp() in index.php at line 20

XF Bug Bot

XenForo bug fixer bot
Staff member
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.2).

Change log:
When merging posts, force the target post to be visible if it will become the first post of the thread.
There may be a delay before changes are rolled out to the XenForo Community.