--- web/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php 2024-10-03 11:04:47.000000000 +0200 +++ web/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php 2024-10-03 11:16:25.000000000 +0200 @@ -25,6 +25,7 @@ use TYPO3\CMS\Extbase\Object\Exception\CannotReconstituteObjectException; use TYPO3\CMS\Extbase\Object\ObjectManagerInterface; use TYPO3\CMS\Extbase\Persistence; +use TYPO3\CMS\Extbase\Persistence\ClassesConfiguration; use TYPO3\CMS\Extbase\Persistence\Generic\Exception; use TYPO3\CMS\Extbase\Persistence\Generic\Exception\UnexpectedTypeException; use TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy; @@ -57,6 +58,10 @@ // @deprecated since v11, will be removed in v12 protected ObjectManagerInterface $objectManager; protected EventDispatcherInterface $eventDispatcher; + /** + * @var ClassesConfiguration + */ + private $classesConfiguration; /** * @var QueryInterface|null @@ -70,7 +75,8 @@ DataMapFactory $dataMapFactory, QueryFactoryInterface $queryFactory, ObjectManagerInterface $objectManager, - EventDispatcherInterface $eventDispatcher + EventDispatcherInterface $eventDispatcher, + ClassesConfiguration $classesConfiguration, ) { $this->reflectionService = $reflectionService; $this->qomFactory = $qomFactory; @@ -80,6 +86,7 @@ // @deprecated since v11, will be removed in v12. $this->objectManager = $objectManager; $this->eventDispatcher = $eventDispatcher; + $this->classesConfiguration = $classesConfiguration; } /** @@ -138,11 +145,17 @@ */ protected function mapSingleRow($className, array $row) { - if ($this->persistenceSession->hasIdentifier($row['uid'], $className)) { - $object = $this->persistenceSession->getObjectByIdentifier($row['uid'], $className); + $classSettings = $this->classesConfiguration->getConfigurationFor($className); + $uidColumnName = 'uid'; + if ($classSettings && array_key_exists($uidColumnName, $classSettings['properties'])) { + $uidColumnName = $classSettings['properties'][$uidColumnName]['fieldName']; + } + + if ($this->persistenceSession->hasIdentifier($row[$uidColumnName], $className)) { + $object = $this->persistenceSession->getObjectByIdentifier($row[$uidColumnName], $className); } else { $object = $this->createEmptyObject($className); - $this->persistenceSession->registerObject($object, $row['uid']); + $this->persistenceSession->registerObject($object, $row[$uidColumnName]); $this->thawProperties($object, $row); $event = new AfterObjectThawedEvent($object, $row); $this->eventDispatcher->dispatch($event);