Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[5.1] Account for __isset changes in PHP 7#13509

Merged
taylorotwell merged 1 commit into
laravel:5.1from
tmiskin:php7-isset-fix
May 11, 2016
Merged

[5.1] Account for __isset changes in PHP 7#13509
taylorotwell merged 1 commit into
laravel:5.1from
tmiskin:php7-isset-fix

Conversation

@tmiskin
Copy link
Copy Markdown
Contributor

@tmiskin tmiskin commented May 10, 2016

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

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
@GrahamCampbell GrahamCampbell changed the title Account for __isset changes in PHP 7 [5.1] Account for __isset changes in PHP 7 May 10, 2016
@srmklive
Copy link
Copy Markdown
Contributor

@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.

@taylorotwell taylorotwell merged commit 45fb881 into laravel:5.1 May 11, 2016
@taylorotwell
Copy link
Copy Markdown
Member

Can y'all test my tweak of this? 09ea8e2

@tmiskin
Copy link
Copy Markdown
Contributor Author

tmiskin commented May 11, 2016

@taylorotwell that works for me

@tmiskin
Copy link
Copy Markdown
Contributor Author

tmiskin commented May 11, 2016

@taylorotwell can we get this merged in to 5.2 as well?

@taylorotwell
Copy link
Copy Markdown
Member

I already merged it forward.

@tmiskin
Copy link
Copy Markdown
Contributor Author

tmiskin commented May 11, 2016

Thanks, in my testing this was the only major issue I had migrating to 7.

@GenPage
Copy link
Copy Markdown

GenPage commented Oct 27, 2016

@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
Copy link
Copy Markdown
Contributor Author

tmiskin commented Oct 27, 2016

@GenPage Taylor implemented a better way to handle this in a subsequent commit, but yes, that will need to be changed in 4.2 for it to work properly.

8fb89c6

@GenPage
Copy link
Copy Markdown

GenPage commented Oct 27, 2016

@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.

@tmiskin
Copy link
Copy Markdown
Contributor Author

tmiskin commented Oct 27, 2016

@GenPage I would open a pull request with that latest commit from 5.3 into 4.2.

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.

4 participants