Bug #71566
openObjectAcess with combination of LazyLoadingProxy fails to fetch bool properties
0%
Description
Hi,
I have a situation, when an object, validated by GenericObjectValidator contains @lazy relation to another object, which itself contains boolean value, fetched by is*() method.
Simplified code:
class MyObject { /** * @var \Vendor\Relation * @lazy */ protected $relation; ... } class Relation { /** * @var boolean */ protected $boolean; public function isBoolean() { return $this->boolean; } }
When 'MyObject' is validated, due to recursive validation 'Relation' is also validated. But at the moment of validation the relation is substituted with LazyLoadingProxy. And, when ObjectAccess asks is_callable(array($proxy, 'getBoolean'))
in getPropertyInternal()
, it receives true
, because it is callable on Proxy, but in fact it is not callable on original object and a PHP error occurs.
Updated by Viktor Livakivskyi about 9 years ago
To be more precise, not PHP Error, but PHP Warning is emitted, but still it is not nice.
Core: Error handler (FE): PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, class '\Vendor\Relation' does not have a method 'getBoolean' in /path/typo3_src/typo3/sysext/extbase/Classes/Persistence/Generic/LazyLoadingProxy.php line 103
Updated by Viktor Livakivskyi about 8 years ago
Another issue related to this: in case Relation
object contains some property, which starts from underscore and doesn't have public ->get...()
method, a similar Exception will appear.
When using no LazyLoadingProxy, property is correctly validated.
E.g.
class Relation { /** * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage */ protected $_myStorage; }