Issue Bug Resolved

#94486Update Model with LazyLoadingProzy

varioous OG 07/06/21, 08:17 updated 10/28/26, 16:05

Description

Hi,

i have a model called “Book” with a field lecturer that is lazy loaded:

    /**
     * @TYPO3\CMS\Extbase\Annotation\ORM\Lazy
     * @var \Varioous\VaTemplate\Domain\Model\Lecturer
     */
    protected $lecturer = null;

Then i want to update a Book B with the lecturer of Book a (via DataHandler -> proccessdatamapHook):

//not working
$book->setLecturer($parent->getLecturer());
$bookRepository->update($book);
$persistenceManager->persistAll();

if i load the lazy loaded instance, it works

if ($parent->getLecturer() instanceof LazyLoadingProxy) {
    $parent->getLecturer()->_loadRealInstance();
}

$book->setLecturer($parent->getLecturer());
$bookRepository->update($book);
$persistenceManager->persistAll();

Should be automatically handled by the update function of the Repository.

Reviews 2

History 57

  1. varioous OG changed project id subject Update Model iwth LazyLoadingProzy Update Model with LazyLoadingProzy TYPO3 Version 10 PHP Version 7.4 Tags repository Complexity easy <span data-processor="relativetime" data-value="2021-07-06T08:18:13+00:00" > 07/06/21, 08:18 </span>

  2. Alexander Schnitzler commented and changed assigned to Alexander Schnitzler target version <span data-processor="relativetime" data-value="2026-10-19T06:24:13+00:00" > 10/19/26, 06:24 </span>

    Still reproducible on main with native lazy objects (since
    ”[FEATURE] Use native PHP lazy objects for Extbase lazy loading”):

    $blog3 = $blogRepository->findByUid(3);
    $blog1 = $blogRepository->findByUid(1);
    $blog1->setAdministrator($blog3->getAdministrator()); // lazy proxy
    $blogRepository->update($blog1);
    $persistenceManager->persistAll();
    // blog 1 administrator stays 0

    It works when the proxy was initialized before the assignment.

    Cause: Backend::persistObject() skips every property whose value
    is an uninitialized lazy object (propertyValueIsLazyLoaded()),
    before the dirty check. That is meant for the object’s own untouched
    lazy relation, but also hits a proxy assigned from another object.
    The uid of the proxy is already set without initializing it.

  3. Anonymous commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-10-28T16:05:12+00:00" > 10/28/26, 16:05 </span>

    Applied in changeset commit:10cc3a7455f1581ef034ffcf29e8687260e44c72.