dustin10 / VichUploaderBundle

A simple Symfony bundle to ease file uploads with ORM entities and ODM documents.
MIT License
1.85k stars 519 forks source link

"Mapping not found for field" after update to doctrine bundle 2.5.0 #1236

Closed janwebdev closed 2 years ago

janwebdev commented 2 years ago

Bug Report

Q A
BC Break yes
Bundle version 1.18.0
Symfony version 4.4.33
PHP version 8.0.13

Summary

after update of project to doctrine bundle 2.5.0 all Vich mappings raise an exception "Mapping not found for field"

Current behavior

all Vich mappings raise an exception "Mapping not found for field". this happens only after the cache of project has been generated

How to reproduce

/**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private $image;

    /**
     * @Assert\NotBlank(groups={"UserAvatar"}, message="You haven't uploaded new image")
     * NOTE: This is not a mapped field of entity metadata, just a simple property.
     * @Vich\UploadableField(mapping="users", fileNameProperty="image")
     * @var File
     */
    private $imageFile;

Expected behavior

no exception as before update

bobvandevijver commented 2 years ago

I think you also updated jms/metadata to 2.6.0, which is breaking BC. See https://github.com/schmittjoh/metadata/issues/108.

janwebdev commented 2 years ago

I think you also updated jms/metadata to 2.6.0, which is breaking BC. See schmittjoh/metadata#108.

Thank for your reply. No, not using JMS at all in project

bobvandevijver commented 2 years ago

@janwebdev That would be impossible as this bundle requires it ;)

https://github.com/dustin10/VichUploaderBundle/blob/dbfe95c7cbe04def86b2e64a5c5ff6c9bb9f515d/composer.json#L20

Anyways, I have the exact same error, but the fix is inbound @ jms.

janwebdev commented 2 years ago

@bobvandevijver Thatnks a lot for your help. It is fixed now ))