#92967makeInstance returns "unclean" instances of objects if used repeatedly
Description
We’ve been porting code to TYPO3 10 and were switching from objectManager->get() to makeInstance() when we noticed that using makeInstance() repeatedly to create a list of new Model instances, the returned instance is a reference to the object that was created before.
Testcase:
$user =$this->feUserRepository->findOneByXid($userData['extId']);
if(!isset($user)){
$user = GeneralUtility::makeInstance(\Vendor\Extension\Domain\Model\FeUser::class);
}
// do stuff
If we repeatedly call this code, on the second user that is being created, makeInstance() returns the object poluted with information from the first user that was created and later persisted. We had to clone the returned object to keep the object cache that makeInstances manages “clean”.
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.