Project

General

Profile

Actions

Bug #92967

closed

makeInstance returns "unclean" instances of objects if used repeatedly

Added by Johannes Rebhan almost 4 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2020-12-01
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.4
Tags:
Complexity:
Is Regression:
Sprint Focus:

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".

Actions

Also available in: Atom PDF