You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling PropertyAccessor::isReadable() on a lazy object’s missing property will trigger an error, even if the object is fully loaded.
This is because PropertyAccessor::getReadInfo() will return the property as public as its class has a __get method, and trying to access it will call trigger_error:
…las-grekas)
This PR was merged into the 6.4 branch.
Discussion
----------
[PropertyAccess] Fix checking for missing properties
| Q | A
| ------------- | ---
| Branch? | 6.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues | Fix#48970, fix#54194, fix#51919
| License | MIT
PropertyAccess and PropertyInfo make a few assumptions when magic methods are involved.
Namely they assume that if a `__get` method is defined, then any property name is accessible.
This assumption is generally wrong, and this becomes more evident with the introduction of lazy objects.
The linked issue gives some more details.
In this PR, I tweak these assumptions in order to make less of them.
Note that there is no bullet-proof way to decide if a *virtual* property exists in PHP. We're missing an `__exists()` magic method for that. Because of this, I'm submitting this PR to 6.4 and not 5.4. Let 5.4 end its life quietly and ensure 6.4 works at its best with lazy ghosts, where they're mainstream.
Commits
-------
9610a7c [PropertyAccess] Fix checking for missing properties
Symfony version(s) affected
≥ 6.2
Description
Calling
PropertyAccessor::isReadable()
on a lazy object’s missing property will trigger an error, even if the object is fully loaded.This is because
PropertyAccessor::getReadInfo()
will return the property as public as its class has a__get
method, and trying to access it will calltrigger_error
:symfony/src/Symfony/Component/VarExporter/LazyGhostTrait.php
Line 193 in 3147082
How to reproduce
Call
PropertyAccessor::isReadable()
on a lazy object’s (like a Doctrine proxy) missing property. Instead offalse
, you’ll get anErrorException
.Possible Solution
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: