Fixed Call to a member function toApiResult() on null - src/XF/Api/Controller/Thread.php:88

Affected version
2.2.4

Lukas W.

Well-known member
Running into this issue quite a lot. Looks like the controller is throwing that if the last post of a thread happens to be the only unread post as well as being ignored:

PHP:
if ($thread->isUnread())
{
   /** @var \XF\Entity\Post $firstUnread */
   $firstUnread = $this->getPostRepo()
      ->findNextPostsInThread($thread, $thread->getVisitorReadDate())
      ->skipIgnored()
      ->with('api')
      ->fetchOne();

   $result['first_unread'] = $firstUnread->toApiResult();
}

Probably either need to return the post even if it's ignored, or remove the first_unread result from the response.
 

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.6).

Change log:
Do not attempt to include a first_unread post in the API when the only unread posts in a thread are ignored.
There may be a delay before changes are rolled out to the XenForo Community.
 
Top