Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Hotfix/avoid sending null embedded objects to hydrators #30

Conversation

matwright
Copy link
Contributor

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

Mat Wright and others added 4 commits July 5, 2016 20:56
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
@veewee veewee added the bug label Jul 6, 2016
@veewee
Copy link
Contributor

veewee commented Jul 6, 2016

Thanks for reporting the bug. Can you add the test case provided in the issue and fix the CS issue?
I guess this one needs to be patched to 2.0 and 1.0 ?

Mat Wright added 3 commits July 6, 2016 10:16
'origin/hotfix/test-case-to-demonstrate-embed-field-break-when-not-set'
into hotfix/avoid-sending-null-embedded-objects-to-hydrators
matwright pushed a commit to matwright/zf-doctrine-hydration-module that referenced this pull request Jul 6, 2016
@matwright
Copy link
Contributor Author

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.

@veewee
Copy link
Contributor

veewee commented Jul 6, 2016

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.

{"files":[{"name":"\/home\/travis\/build\/phpro\/zf-doctrine-hydration-module\/src\/Hydrator\/ODM\/MongoDB\/Strategy\/EmbeddedField.php","appliedFixers":["braces"]}],"memory":7.5,"time":{"total":0.103}}

The warning about mongo is 'normal'. The doctrine-odm repository also has this problem.

@matwright
Copy link
Contributor Author

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 ?

@veewee
Copy link
Contributor

veewee commented Jul 6, 2016

That build is running with DEPENDENCIES=low which will run composer update --prefer-lowest. So it might be due to an issue in the cs fixer or a fixer that works in a different way then the old version.

@matwright
Copy link
Contributor Author

yes that would explain.

veewee added a commit that referenced this pull request Jul 8, 2016
…ded-objects-to-hydrators-v1

fix bug #30 for version 1.x
@veewee veewee merged commit 9f657f0 into phpro:master Jul 8, 2016
@veewee
Copy link
Contributor

veewee commented Jul 8, 2016

Thanks!

@veewee veewee added this to the 2.0.2 milestone Jul 8, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants