Issue Bug Resolved

#107070Domain Object Valdiation does not handle LazyLoadingProxies

Ramon Zöllner 07/10/25, 14:58 updated 10/18/26, 07:05

Description

It is basically the same issue as #92357.

When declaring a object property #[Lazy] it will result in an error as the LazyLoadingProxy is not thawed. This does not happen with ObjectStorages.

It used to work with TYPO3 11 but in 12 the error showed up again.

In 11 the solution was to resolve the Proxy within a magic getter. Somehow this getter is not getting called anymore and I was not able to convince ObjectAccess::isPropertyGettable to do so.

What helped is resolving the proxy directly before the check as suggested in #92357 (see provided patch).

Reviews 3

Files 1

History 34

  1. Torben Hansen commented and changed status New Needs Feedback <span data-processor="relativetime" data-value="2025-07-13T17:35:52+00:00" > 07/13/25, 17:35 </span>

    Please provide some more input on which error message occurs and what code you use (e.g. simplified domain model).

    As far as I know, lazy loading for non ObjectStorage properties also require types of the property to support at least LazyLoadingProxy. This is an example from a core fixture extension:

    #[Lazy]
    protected Administrator|LazyLoadingProxy|null $administrator = null;
  2. Gerrit Code Review pushed patch set 1 for main to change 96794 status Needs Feedback Under Review <span data-processor="relativetime" data-value="2026-10-17T15:51:24+00:00" > 10/17/26, 15:51 </span>

  3. Alexander Schnitzler commented <span data-processor="relativetime" data-value="2026-10-17T15:55:02+00:00" > 10/17/26, 15:55 </span>

    I think this is resolved on main.

    Since 9abd0164b76 “[FEATURE] Use native PHP lazy objects for Extbase lazy loading” (95039, #110347), a #[Lazy] 1:1 or n:1 relation is no longer a LazyLoadingProxy. @DataMapper::createLazyEntityProxy()@ creates a native PHP lazy object of the target entity class, which is initialized on first access. Validators therefore receive an instance of the related model, and the base validator descends into the relation as for an eagerly loaded object. This is part of main (v15) and not released yet.

    The change came without a validation test. 96794 adds LazyRelationValidationTest with the blog_example fixtures (Blog::$featuredPost and Blog::$administrator, typed Administrator|LazyLoadingProxy|null as in the example from the comments):

    • lazyToOneRelationLoadedFromDatabaseIsNoLazyLoadingProxy
    • baseValidatorReportsErrorOfUnresolvedLazyToOneRelation: the error shows up at the path of the relation (featuredPost.title)
    • baseValidatorAcceptsValidUnresolvedLazyToOneRelation
    • propertyValidatorOfLazyAdministratorRunsAgainstResolvedRecord
    • propertyValidatorOfLazyAdministratorReportsErrorOfResolvedRecord

    On 14.3 and 13.4 the DataMapper still creates LazyLoadingProxy instances. On 14.3 the problem is only partly fixed: 4f53b5a0a70 (95542, #71566, since 14.3.7) resolves the proxy in __isset(), but validation still fails with a RuntimeException (“Could not get value of property”) when a validated property of the proxied entity is null. On 13.4 it is not fixed. The fix will not be backported to these branches.

    If this should also be fixed on 14.3 and/or prior versions, I recommend consulting @benni regarding the impact.

  4. Anonymous commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-10-18T07:05:19+00:00" > 10/18/26, 07:05 </span>

    Applied in changeset commit:6bdff22d99f89e4ba0b0d10d97e88e006d500890.