[BUGFIX] Harden Extbase LazyLoadingProxy
When a domain model object has a lazy loading property (e.g. relation to another domain model object), the `AbstractGenericObjectValidator` may fail validation the domain model, if the database record for the related object has been deleted. This change fixes the problem by adding a null safe operator to the `$realInstance` variable in the magic `__get` call in LazyLoadingProxy. The return type for `_loadRealInstance` has been adapted, since the function actually can return `null`. This allows the removal of an entry in the phpstan baseline file. Additionally a todo in `AbstractGenericObjectValidator` has been removed, since the function actually supports lazy loading proxies as the initial error shows. Resolves: #101400 Releases: main, 12.4 Signed-off-by:Torben Hansen <derhansen@gmail.com> Change-Id: Ib39da09fdc94ef529f672af7f948d6a7fd82e531 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80104 Tested-by:
Oliver Klee <typo3-coding@oliverklee.de> Reviewed-by:
Oliver Klee <typo3-coding@oliverklee.de> Tested-by:
Alexander Schnitzler <git@alexanderschnitzler.de> Reviewed-by:
Nikita Hovratov <nikita.h@live.de> Tested-by:
core-ci <typo3@b13.com> Reviewed-by:
Alexander Schnitzler <git@alexanderschnitzler.de> Tested-by:
Nikita Hovratov <nikita.h@live.de>
Showing
- Build/phpstan/phpstan-baseline.neon 0 additions, 5 deletionsBuild/phpstan/phpstan-baseline.neon
- typo3/sysext/extbase/Classes/Persistence/Generic/LazyLoadingProxy.php 2 additions, 2 deletions.../extbase/Classes/Persistence/Generic/LazyLoadingProxy.php
- typo3/sysext/extbase/Classes/Validation/Validator/AbstractGenericObjectValidator.php 0 additions, 1 deletion...s/Validation/Validator/AbstractGenericObjectValidator.php
- typo3/sysext/extbase/Tests/Functional/Persistence/LazyLoadingProxyTest.php 11 additions, 0 deletions...ase/Tests/Functional/Persistence/LazyLoadingProxyTest.php
Please register or sign in to comment