diff --git a/core/metamodel.class.php b/core/metamodel.class.php index d258c1823..c03ac387a 100644 --- a/core/metamodel.class.php +++ b/core/metamodel.class.php @@ -6846,18 +6846,6 @@ abstract class MetaModel $sClass = $aRow[$sClassAlias."finalclass"]; } - // if an object is already being updated, then this method will return this object instead of recreating a new one. - // At this point the method DBUpdate of a new object with the same class and id won't do anything due to reentrance protection, - // so to ensure that the potential modifications are correctly saved, the object currently being updated is returned. - // DBUpdate() method then will take care that all the modifications will be saved. - if (array_key_exists($sClassAlias.'id', $aRow)) { - $iKey = $aRow[$sClassAlias."id"]; - $oObject = self::GetReentranceObject($sClass, $iKey); - if ($oObject !== false) { - return $oObject; - } - } - return new $sClass($aRow, $sClassAlias, $aAttToLoad, $aExtendedDataSpec); } diff --git a/tests/php-unit-tests/unitary-tests/core/DBObjectTest.php b/tests/php-unit-tests/unitary-tests/core/DBObjectTest.php index 608297a5a..433032aca 100644 --- a/tests/php-unit-tests/unitary-tests/core/DBObjectTest.php +++ b/tests/php-unit-tests/unitary-tests/core/DBObjectTest.php @@ -931,32 +931,6 @@ class DBObjectTest extends ItopDataTestCase $this->assertEquals($sPerson2, $sPerson3); } - public function testGetObjectUpdateUnderReentryProtection() - { - $oPerson = $this->CreatePersonInstance(); - $oPerson->DBInsert(); - - $oPerson->Set('email', 'test@combodo.com'); - $oPerson->DBUpdate(); - - $this->assertFalse($oPerson->IsModified()); - - $oNewPerson = MetaModel::GetObject('Person', $oPerson->GetKey()); - $this->assertNotEquals($oPerson->GetObjectUniqId(), $oNewPerson->GetObjectUniqId()); - - MetaModel::StartReentranceProtection($oPerson); - - $oPerson->Set('email', 'test1@combodo.com'); - $oPerson->DBUpdate(); - - $this->assertTrue($oPerson->IsModified()); - - $oNewPerson = MetaModel::GetObject('Person', $oPerson->GetKey()); - $this->assertEquals($oPerson->GetObjectUniqId(), $oNewPerson->GetObjectUniqId()); - - MetaModel::StopReentranceProtection($oPerson); - } - public function testObjectIsReadOnly() { $oPerson = $this->CreatePersonInstance(); diff --git a/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-config/CRUD/DBObjectTest.php b/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-config/CRUD/DBObjectTest.php index 914110fc7..03df03c54 100644 --- a/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-config/CRUD/DBObjectTest.php +++ b/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-config/CRUD/DBObjectTest.php @@ -156,7 +156,7 @@ class DBObjectTest extends ItopDataTestCase $this->assertTrue($oPerson->IsModified()); $oNewPerson = MetaModel::GetObject('Person', $oPerson->GetKey()); - $this->assertEquals($oPerson->GetObjectUniqId(), $oNewPerson->GetObjectUniqId()); + $this->assertNotEquals($oPerson->GetObjectUniqId(), $oNewPerson->GetObjectUniqId()); MetaModel::StopReentranceProtection($oPerson); }