From f281fa7b1481fbc9220789eaa405481c6af26f1b Mon Sep 17 00:00:00 2001 From: jf-cbd Date: Tue, 29 Oct 2024 11:21:04 +0100 Subject: [PATCH 1/2] :zap: Remove unnecessary reload --- core/dbobject.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/core/dbobject.class.php b/core/dbobject.class.php index 4f63633e2..58e2daa04 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -3494,6 +3494,7 @@ abstract class DBObject implements iDisplay $this->m_bIsInDB = true; $this->m_bDirty = false; + $this->m_bFullyLoaded = true; foreach ($this->m_aCurrValues as $sAttCode => $value) { if (is_object($value)) { $value = clone $value; From 561baf5771f6c76b6c9cf9dc33980e79cd3910a8 Mon Sep 17 00:00:00 2001 From: jf-cbd Date: Thu, 31 Oct 2024 09:32:58 +0100 Subject: [PATCH 2/2] :white_check_mark: update tests to comply with expected behavior --- tests/php-unit-tests/unitary-tests/core/DBObjectTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/php-unit-tests/unitary-tests/core/DBObjectTest.php b/tests/php-unit-tests/unitary-tests/core/DBObjectTest.php index 84ab44413..7c97e4044 100644 --- a/tests/php-unit-tests/unitary-tests/core/DBObjectTest.php +++ b/tests/php-unit-tests/unitary-tests/core/DBObjectTest.php @@ -319,11 +319,11 @@ class DBObjectTest extends ItopDataTestCase $this->DebugReloadCount("Get('org_id_friendlyname') and Get('location_id_friendlyname')"); // External key given as an id - $this->assertDBQueryCount(2, function() use (&$oObject){ + $this->assertDBQueryCount(1, function() use (&$oObject){ $oObject->Set('org_id', 2); static::assertEquals('IT Department', $oObject->Get('org_id_friendlyname')); }); - $this->assertEquals(1, $this->GetObjectReloadCount($sClass, $sKey)); + $this->assertEquals(0, $this->GetObjectReloadCount($sClass, $sKey)); $this->DebugReloadCount("Set('org_id', 2) and Get('org_id_friendlyname')"); // External key given as an object @@ -387,7 +387,7 @@ class DBObjectTest extends ItopDataTestCase $this->assertCount(0, $oTeam->ListChanges()); // External key given as an id - $this->assertDBQueryCount(2, function() use (&$oTeam){ + $this->assertDBQueryCount(1, function() use (&$oTeam){ $oTeam->Set('org_id', 2); static::assertEquals('IT Department', $oTeam->Get('org_id_friendlyname')); });