diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 041531ecc1..fb205851ed 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -5960,7 +5960,6 @@ JS final protected function FireEventAfterDelete(): void { $this->NotifyAttachedObjectsOnLinkClassModification(); - $this->FireEventDbLinksChangedForCurrentObject(); $this->FireEvent(EVENT_DB_AFTER_DELETE); } @@ -6101,10 +6100,7 @@ JS MetaModel::StartReentranceProtection($oObject); $oObject->FireEvent(EVENT_DB_LINKS_CHANGED); MetaModel::StopReentranceProtection($oObject); - - // Use IsNew() === true when object is deleted - // new objects are already saved at this point (so IsNeww() will return false in this case) - if (!$oObject->IsNew() && count($oObject->ListChanges()) !== 0) { + if (count($oObject->ListChanges()) !== 0) { $oObject->DBUpdate(); } } diff --git a/core/dbobject.class.php b/core/dbobject.class.php index b0dfd5aa76..38da353561 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -4278,11 +4278,6 @@ abstract class DBObject implements iDisplay /** @var \DBObject $oToDelete */ $oToDelete = $aData['to_delete']; - if ($oToDelete === $this) { - // Skip current object to delete it at the end - continue; - } - // The deletion based on a deletion plan should not be done for each object if the deletion plan is common (Trac #457) // because for each object we would try to update all the preceding ones... that are already deleted // A better approach would be to change the API to apply the DBDelete on the deletion plan itself... just once @@ -4301,14 +4296,6 @@ abstract class DBObject implements iDisplay } } - $this->AddCurrentObjectInCrudStack('DELETE'); - try { - $this->DBDeleteSingleObject(); - } - finally { - $this->RemoveCurrentObjectInCrudStack(); - } - foreach ($oDeletionPlan->ListUpdates() as $sClass => $aToUpdate) { foreach ($aToUpdate as $aData) { $oToUpdate = $aData['to_reset']; diff --git a/datamodels/2.x/itop-tickets/main.itop-tickets.php b/datamodels/2.x/itop-tickets/main.itop-tickets.php index 82248e2c4e..626de74e7e 100755 --- a/datamodels/2.x/itop-tickets/main.itop-tickets.php +++ b/datamodels/2.x/itop-tickets/main.itop-tickets.php @@ -134,11 +134,6 @@ class _Ticket extends cmdbAbstractObject public function UpdateImpactedItems() { - if ($this->IsNew() && ($this->GetKey() > 0)) { - // deleted ticket - return; - } - require_once(APPROOT.'core/displayablegraph.class.inc.php'); /** @var ormLinkSet $oContactsSet */ $oContactsSet = $this->Get('contacts_list'); diff --git a/tests/php-unit-tests/unitary-tests/core/CRUDEventTest.php b/tests/php-unit-tests/unitary-tests/core/CRUDEventTest.php index 66c8663e59..024cfcc1b9 100644 --- a/tests/php-unit-tests/unitary-tests/core/CRUDEventTest.php +++ b/tests/php-unit-tests/unitary-tests/core/CRUDEventTest.php @@ -423,8 +423,8 @@ class CRUDEventTest extends ItopDataTestCase // 1 delete for UserRequest, 3 delete for lnkFunctionalCIToTicket $this->assertEquals(4, self::$aEventCalls[EVENT_DB_CHECK_TO_DELETE]); $this->assertEquals(4, self::$aEventCalls[EVENT_DB_AFTER_DELETE]); - $this->assertEquals(1, self::$aEventCalls[EVENT_DB_LINKS_CHANGED] ?? 0); - $this->assertEquals(9, self::$iEventCalls); + $this->assertArrayNotHasKey(EVENT_DB_LINKS_CHANGED, self::$aEventCalls, 'no relation with the with_php_compute attribute !'); + $this->assertEquals(8, self::$iEventCalls); }