#94486Update Model with LazyLoadingProzy
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
Related issues 1
History 57
-
varioous OG changed project id subject
Update Model iwth LazyLoadingProzyUpdate Model with LazyLoadingProzy TYPO3 Version 10 PHP Version 7.4 Tags repository Complexity easy 07/06/21, 08:18 -
Alexander Schnitzler changed Related to #111139 10/19/26, 06:22
-
Alexander Schnitzler commented and changed assigned to Alexander Schnitzler target version 10/19/26, 06:24
-
Alexander Schnitzler changed category 10/19/26, 06:24
-
Gerrit Code Review pushed patch set 1 for main to change 96848 status
NewUnder Review 10/19/26, 06:39 -
Gerrit Code Review pushed patch set 2 for main to change 96848 10/19/26, 06:55
-
Anonymous commented and changed status
Under ReviewResolved done0 %100 % 10/28/26, 16:05Applied in changeset commit:10cc3a7455f1581ef034ffcf29e8687260e44c72.
Still reproducible on main with native lazy objects (since
”[FEATURE] Use native PHP lazy objects for Extbase lazy loading”):
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.