Reply to thread

XF\Entity\CoverImageTrait::getCoverImageInternal()


[php]

/** @var Attachment $attachment */

if ($embeddedAttachments[$attachment->attachment_id])

{

    continue;

}

[/php]


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

[php]

public function offsetGet($key): ?Entity

{

    return $this->entities[$key];

}

[/php]


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.


Back
Top Bottom