Not a bug getValidatedRecipients assumes $recipients is always array

TickTackk

Well-known member
Affected version
2.*
Will throw exception if an array collection was provided.

PHP:
        $first = reset($recipients);
        if ($first instanceof \XF\Entity\User)
        {
            $type = 'user';
        }
        else
        {
            $type = 'name';
        }

Should be
PHP:
        if ($recipients instanceof \XF\Mvc\Entity\AbstractCollection)
        {
            $first = $recipients->first();
        }
        else
        {
            $first = reset($recipients);
        }

        if ($first instanceof \XF\Entity\User)
        {
            $type = 'user';
        }
        else
        {
            $type = 'name';
        }
 
Strictly speaking, this isn't a bug as we only ever pass in a comma separated string of recipients (which we convert to an array) or a single User entity (also converted to an array).

I've made the change, regardless.
 
Back
Top Bottom