Skip to content

GalleryProcessor breaks with "Folder from Storage" file collections — File wrongly treated as FileReference #902

Description

@lafllamme

Bug Report

Current behavior

FileUtility::process() accepts a FileInterface, but unconditionally treats it as a FileReference:

$fileReferenceUid = $fileReference->getUid();
$uidLocal = $fileReference->getProperty('uid_local');

When the GalleryProcessor loads images through a "Folder from Storage" FileCollection, the file objects are plain \TYPO3\CMS\Core\Resource\File instances, not FileReferences. In that case the file's own uid ends up in fileReferenceUid while uidLocal stays null.

GalleryProcessor::prepareGalleryData() then re-resolves every image with treatIdAsReference: true:

$src = $this->processorConfigurationObject->legacyReturn ? $fileObj['properties']['fileReferenceUid'] : $fileObj['fileReferenceUid'];
$image = $this->getImageService()->getImage((string)$src, null, true);

So a plain file uid is interpreted as a sys_file_reference uid, which resolves to the wrong image (or fails) for folder-based collections.

Expected behavior

Plain File objects should be output with uidLocal set and fileReferenceUid: null, and the GalleryProcessor should only resolve via reference when a reference uid actually exists.

Steps to reproduce

  1. Create a file collection of type "Folder from Storage" containing images.
  2. Render it via a content element that uses the GalleryProcessor (e.g. textmedia).
  3. Observe the wrong or broken image output in the JSON response.

Fix

We fixed this on our fork by only reading uid_local when the object is instanceof FileReference, and by falling back to uidLocal (with treatIdAsReference: false) in GalleryProcessor when fileReferenceUid is null — unit test baselines updated accordingly:

master...Digi92:feature/galleryprocessor-file-handling

I hope this can be fixed asap, as this breaks our whole image setup for carousal galleries in TYPO3.

CC @Digi92

Happy to open a PR from that branch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions