-
Notifications
You must be signed in to change notification settings - Fork 35
Hotfix/avoid sending null embedded objects to hydrators #30
Hotfix/avoid sending null embedded objects to hydrators #30
Conversation
the $value argument must be an object as per annotations in the $hydrator->extract() method which is called within this method. Passing other values, particularly null values causes exceptions to be thrown.
test case to demonstrate that embed field hydration fails when the embedded file is not set (null or not-exists in DB)
updated param docbloc annotation test if not object then return same value
Thanks for reporting the bug. Can you add the test case provided in the issue and fix the CS issue? |
'origin/hotfix/test-case-to-demonstrate-embed-field-break-when-not-set' into hotfix/avoid-sending-null-embedded-objects-to-hydrators
Fixed CS, the build is failing one of the automated checks but looks like its an environment error with mongo not code related ? I also updated the test to assert that the getEmbed returns null when not set. Will send a PR for version 1.0 also. |
The error in Travis is related to php-cs-fixer. Maybe the minimum version should just be bumped to a newer version since it is just a dev dependency.
The warning about mongo is 'normal'. The doctrine-odm repository also has this problem. |
Yes I have the mongo warning here too. But the cs-fixer is strange, why is it failing only on that one build for that specific file ? |
That build is running with DEPENDENCIES=low which will run |
yes that would explain. |
…ded-objects-to-hydrators-v1 fix bug #30 for version 1.x
Thanks! |
EmbedField Strategy extract() method should only accept object values.
When an embed field is not set or null a php null value is passed to this method and passed onto the DoctrineHydrator extract method that expects an object, this causes Exceptions to be thrown further down the line when the ClassMethods class is invoked using a get_class function call on the null value.
#29