jbouzekri / FileUploaderBundle

Aggregate some bundles and libraries to provide easy ajax file upload integration with crop
MIT License
23 stars 7 forks source link

The identifier fileName is missing for a query of Jb\Bundle\FileUploaderBundle\Entity\FileHistory #16

Closed niangoss closed 7 years ago

niangoss commented 7 years ago

at ORMException ::missingIdentifierField ('Jb\Bundle\FileUploaderBundle\Entity\FileHistory', 'fileName') in vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php at line 403 + at EntityManager ->find ('Jb\Bundle\FileUploaderBundle\Entity\FileHistory', null, null, null) in vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php at line 154 + at EntityRepository ->find (null) in vendor/jbouzekri/file-uploader-bundle/Jb/Bundle/FileUploaderBundle/Service/Validator/Constraints/FileOwnerValidator.php at line 55 +

niangoss commented 7 years ago

Hello I was facing to this issue that is come from to your validate method of your validator \Jb\Bundle\FileUploaderBundle\Service\Validator\Constraints\FileOwnerValidator::validate.

at this line : $fileHistory = $this->em->getRepository('JbFileUploaderBundle:FileHistory')->find($value);

Issue is due to the default null value of my field $image passed as parameter to find method.

/* * @ORM\Column(type="string", length=100, nullable=true) * @JbAssert\FileOwner / protected $image;

Here the nullable is set to true and.

I fixed it by adding this verification before the call of find method: if(!$value){ return; }

jbouzekri commented 7 years ago

Thank you for pointing that out. Sorry I won't be able to look into this before Monday.

The fix you are proposing seems good. Can you make a pull request ?

jbouzekri commented 7 years ago

Done in latest release.