Skip to content

Conversation

@shmax
Copy link
Contributor

@shmax shmax commented May 27, 2017

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 __isset magic method in Model only checks its own $attributes and $alias_attributes properties 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

  • added checks to __isset for getters and relationships
  • expanded existing test_isset test to check a relationship
  • removed an assert from RelationShipTest::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 __isset does not cause any unintended database queries.

Reviewers

@dfyx @hising @erayd

@shmax shmax force-pushed the fix-isset-for-relationships branch 2 times, most recently from 230ba6d to c2527ac Compare May 27, 2017 18:39
@shmax shmax force-pushed the fix-isset-for-relationships branch from 5fe1b6e to 9196cbd Compare May 27, 2017 18:44
@shmax shmax merged commit 8347c57 into master May 28, 2017
@shmax shmax deleted the fix-isset-for-relationships branch May 28, 2017 16:05
@ipundit ipundit mentioned this pull request Aug 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants