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

Kirby

Well-known member
Affected version
2.3.4
XF\Entity\CoverImageTrait::getCoverImageInternal()

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

This calls \XF\Mvc\AbstractCollection::offsetGet()
PHP:
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 ...

It's a bit tricky to actually see this warning as \XF\Template\Templater::handleTemplateError() hides it so this needs to be called by code outside of templater context.
 
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.3.5).

Change log:
Fix potentially undefined array key when determining an entity cover image
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom