Unnesessary query for non-mirrored media items


Well-known member
Affected version
In XF\Pub\Controller\Media::actionIndex
$mirrorAttachment = $mediaItem->MirrorAttachment;

This does gall get getMirrorAttachment on the entity which moreless unconditionally issues a query:
public function getMirrorAttachment()
    $attachment = $this->Attachment;
    if (!$attachment)
        return null;

    return $this->_em->findOne('XF:Attachment', [
        'data_id' => $attachment->data_id,
        'xfmg_is_mirror_handler' => 1

This query seems useless for non-mirrored media items as it will never return a result.
Especially if there are no mirrored media items at all (which at least I would envision to be a pretty common scenario) this seems wasteful and should be avoided.
Top Bottom