Skip to content

Conversation

@mkittl
Copy link

@mkittl mkittl commented Dec 3, 2025

This pull request is related too: #5693

When an image already exists in the media library and there is an image variant with the same image dimensions, re-uploading the image to a tag does not work. This ensures image variants are replaced with the original asset during re-upload.

resolved:#5693

@dlubitz
Copy link
Contributor

dlubitz commented Dec 3, 2025

Thank you @mkittl for reporting and fixing this issue.

I had a quick look into your solution. This might fix the issue, but I wonder why the uploadAction get's the variant instead of the orignal image asset. I would assume the error is rather way before this action. Maybe in the property mapper? (IDK atm where this happens) The wrong asset gets loaded for the SHA and this results in this error.

I think we better should fix the root cause, instead of handle it in the action.

@kitsunet
Copy link
Member

kitsunet commented Dec 3, 2025

I think the cause is indeed the converter, IMHO what happens is the following:

AssetController->uploadAction(Asset $asset) uses the AssetInterfaceConverter,
if CONFIGURATION_ONE_PER_RESOURCE is true (it is for that controller usually and that makes sense) it will try to find an existing asset with the same resource (sha1), the problem is intrinsic to a Variant with the exact same resource, as this Variant will be a valid AssetInterface with the same sha1, so we end up in:
\Neos\Media\Domain\Repository\AssetRepository::findOneByResourceSha1
and probably depending on the UUID order either return the Image or it's Variant. We should probably have a specific query method that searches by sha1 but excludes variants. Which then could be used by the converter (and probably most cases).
That said we should actually go one step further and forbid variants with the same sha1 as the source asset it's coming from?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants