Fixed 'ignoring' is not instance of ArrayCollection when no users are ignored

TickTackk

Well-known member
Affected version
2.1
In XF\Pub\Controller\Account


PHP:
        if ($ignored = $visitor->Profile->ignored)
        {
            $ignoringUsers = $this->finder('XF:User')
                ->where('user_id', array_keys($ignored))
                ->order('username')
                ->fetch();
        }
        else
        {
            $ignoringUsers = [];
        }

Should be:
PHP:
        if ($ignored = $visitor->Profile->ignored)
        {
            $ignoringUsers = $this->finder('XF:User')
                ->where('user_id', array_keys($ignored))
                ->order('username')
                ->fetch();
        }
        else
        {
            $ignoringUsers = new ArrayCollection([]);
        }
 
It never hurts to be type consistent but this doesn't actually cause any negative side effects as it is so while we will probably change this, it would be really useful if you could provide some actual context to bug reports as that may be relevant.
 
Would use
Code:
$ignoringUsers =  \XF::em()->getEmptyCollection();
Does essentially the same, but makes it subject to class extensions.
I could be wrong but entity manager is never extended and should never be extended. So calling `getEmptyCollection() vs. calling new ArrayCollection([]); is non trivial.
 
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.0 Beta 2).

Change log:
Return an empty collection when a user isn't ignoring anyone
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom