Fixed N+1 query behaviour in XF\FindNew\ProfilePost::getResultIds

Xon

Well-known member
Affected version
2.2.2
PHP:
public function getResultIds(array $filters, $maxResults)
{
   /** @var \XF\Finder\ProfilePost $profilePostFinder */
   $profilePostFinder = \XF::finder('XF:ProfilePost')
      ->where('message_state', '<>', 'moderated')
      ->where('message_state', '<>', 'deleted')
      ->order('post_date', 'DESC');

   $this->applyFilters($profilePostFinder, $filters);

   $profilePosts = $profilePostFinder->fetch($maxResults);
   $profilePosts = $this->filterResults($profilePosts);

filterResults() calls \XF\Entity\ProfilePost::canView() which touches ProfileUser, which can result in some silly high query counts on the New Profile posts page before it redirects to the caches query list.

getPageResultsEntities avoids this as it fetches much more data for display.
 
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.3).

Change log:
Fix N+1 query issues when viewing attempting to find new profile posts.
There may be a delay before changes are rolled out to the XenForo Community.
 
Top Bottom