Fix isset for relationships #9
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fix for #8
See also:
jpfuentes2/php-activerecord#156
http://www.phpactiverecord.org/boards/4/topics/1678-php-ar-and-twig
The issue is that the
__issetmagic method inModelonly checks its own$attributesand$alias_attributesproperties and doesn't consider other possibilities, such as magic getters and relationships. I'm using a fix proposed by @dfyx that handles these use cases. Thanks, @dfyx!Changes
__issetfor getters and relationshipstest_issettest to check a relationshipRelationShipTest::test_eager_loading_has_many_array_of_includes. It was no longer passing with the fix for__isset, and it didn't seem to provide any value as the check it was doing would always pass, regardless of whether you were eager loading or not. I verified that, and also that the expanded__issetdoes not cause any unintended database queries.Reviewers
@dfyx @hising @erayd