-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.1] Account for __isset changes in PHP 7 #13509
Conversation
Update: this is a revised PR after speaking with Taylor about the intended behavior and possible solutions. PHP 7 has fixed a bug with __isset which affects both the native isset and empty methods. This causes specific issues with checking isset or empty on relations in Eloquent. In PHP 7 checking if a property exists on an unloaded relation, for example isset($this->relation->id) is always returning false because unlike PHP 5.6, PHP 7 is now checking the offset of each attribute before chaining to the next one. In PHP 5.6 it would eager load the relation without checking the offset. This change brings back the intended behavior of the core Eloquent model __isset method for PHP 7 so it works like it did in PHP 5.6. For reference, please check the following link, specifically Nikita Popov's comment (core PHP dev) - https://bugs.php.net/bug.php?id=69659
@tmiskin I ran into the same issue while using Laravel on PHP 7. Great work on this one. Hopefully this gets merged into the framework. |
Can y'all test my tweak of this? 09ea8e2 |
@taylorotwell that works for me |
@taylorotwell can we get this merged in to 5.2 as well? |
I already merged it forward. |
Thanks, in my testing this was the only major issue I had migrating to 7. |
@taylorotwell Any possibility to cherry-pick this for 4.2? Running into this issue trying to use a prod 4.2 app with PHP7. |
@tmiskin Thank you for the follow-up! Good to hear. Was mainly curious if there was any intention to backporting to 4.2 or if I would need to consider our own solution. |
@GenPage I would open a pull request with that latest commit from 5.3 into 4.2. |
Update: this is a revised PR after speaking with Taylor about the intended behavior and possible solutions.
PHP 7 has fixed a bug with __isset which affects both the native isset and empty methods. This causes specific issues with checking isset or empty on relations in Eloquent. In PHP 7 checking if a property exists on an unloaded relation, for example
isset($this->relation->id)
is always returning false because unlike PHP 5.6, PHP 7 is now checking the offset of each attribute before chaining to the next one. In PHP 5.6 it would eager load the relation without checking the offset. This change brings back the intended behavior of the core Eloquent model __isset method for PHP 7 so it works like it did in PHP 5.6.For reference, please check the following link, specifically Nikita Popov's comment (core PHP dev) - https://bugs.php.net/bug.php?id=69659