Bug \XF\Entity\Thread::getCoverUrl() may cause undefined array key

There is a bug in this version
K

Kirby

Guest
XF\Entity\CoverImageTrait::getCoverImageInternal()

PHP:

Code:
/** @var Attachment $attachment */
if ($embeddedAttachments[$attachment->attachment_id])
{
    continue;
}

This calls \XF\Mvc\AbstractCollection::offsetGet()
PHP:

Code:
public function offsetGet($key): ?Entity
{
    return $this->entities[$key];
}

As can be seen, this directly accesses the internal array without checking if the key exists, so if it does not exist this generates a warning Undefined array key ......

Read more

Continue reading...