diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 96e50a0e9..3726c0248 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -5669,36 +5669,18 @@ JS * @inheritDoc * @since 3.1.0 */ - final protected function EventCreateRequested(): void + final protected function EventCheckToWrite(): void { - $this->FireEvent(EVENT_DB_CREATE_REQUESTED); + $this->FireEvent(EVENT_DB_CHECK_TO_WRITE); } /** * @inheritDoc * @since 3.1.0 */ - final protected function EventCheckToCreate(): void + final protected function EventCheckToWriteFailed(array $aIssues): void { - $this->FireEvent(EVENT_DB_CHECK_TO_CREATE); - } - - /** - * @inheritDoc - * @since 3.1.0 - */ - final protected function EventCheckToCreateFailed(array $aIssues): void - { - $this->FireEvent(EVENT_DB_CHECK_TO_CREATE_FAILED, ['check_issues' => $aIssues]); - } - - /** - * @inheritDoc - * @since 3.1.0 - */ - final protected function EventAboutToCreate(): void - { - $this->FireEvent(EVENT_DB_ABOUT_TO_CREATE); + $this->FireEvent(EVENT_DB_CHECK_TO_WRITE_FAILED, ['check_issues' => $aIssues]); } /** @@ -5714,42 +5696,6 @@ JS /// UPDATE /// - /** - * @inheritDoc - * @since 3.1.0 - */ - final protected function EventUpdateRequested(): void - { - $this->FireEvent(EVENT_DB_UPDATE_REQUESTED); - } - - /** - * @inheritDoc - * @since 3.1.0 - */ - final protected function EventCheckToUpdate(): void - { - $this->FireEvent(EVENT_DB_CHECK_TO_UPDATE); - } - - /** - * @inheritDoc - * @since 3.1.0 - */ - final protected function EventCheckToUpdateFailed(array $aIssues): void - { - $this->FireEvent(EVENT_DB_CHECK_TO_UPDATE_FAILED, ['check_issues' => $aIssues]); - } - - /** - * @inheritDoc - * @since 3.1.0 - */ - final protected function EventAboutToUpdate(): void - { - $this->FireEvent(EVENT_DB_ABOUT_TO_UPDATE); - } - /** * @inheritDoc * @since 3.1.0 @@ -5781,15 +5727,6 @@ JS $this->FireEvent(EVENT_DB_CHECK_TO_DELETE_FAILED, ['check_issues' => $aIssues]); } - /** - * @inheritDoc - * @since 3.1.0 - */ - final protected function EventAboutToDelete(): void - { - $this->FireEvent(EVENT_DB_ABOUT_TO_DELETE); - } - /** * @inheritDoc * @since 3.1.0 diff --git a/application/datamodel.application.xml b/application/datamodel.application.xml index 27c3b189b..9f89d7563 100644 --- a/application/datamodel.application.xml +++ b/application/datamodel.application.xml @@ -186,25 +186,8 @@ - - An object create in the database has been requested. All changes to the object will be persisted automatically. - - cmdbAbstractObject - - DBObject::OnInsert - - - The object inserted - DBObject - - - Debug string - string - - - - - Check an object before it is created into the database (no change possible). Call DBObject::AddCheckIssue() to signal an issue + + Check an object before it is written into the database (no change possible). Call DBObject::AddCheckIssue() to signal an issue cmdbAbstractObject @@ -220,17 +203,12 @@ - - A check has failed, it is not possible to create the object + + A check has failed, it is not possible to write the object in DB cmdbAbstractObject - cmdbAbstractObject::DoCheckToWrite - - Array of the issues (string) that prevented the object creation - array - The object to check DBObject @@ -241,23 +219,6 @@ - - An object is about to be created in the database (no change possible) - - cmdbAbstractObject - - DBObject::OnInsert - - - The object inserted - DBObject - - - Debug string - string - - - An object has been created into the database. The modifications can be propagated to other objects. @@ -275,78 +236,6 @@ - - An object update has been requested. All changes to the object will be persisted automatically. - - cmdbAbstractObject - - DBObject::OnUpdate, DBObject::DoComputeValues - - - The object updated - DBObject - - - Debug string - string - - - - - Check an object before it is written into the database (no change possible). Call DBObject::AddCheckIssue() to signal an issue - - cmdbAbstractObject - - cmdbAbstractObject::DoCheckToWrite - - - The object to check - DBObject - - - Debug string - string - - - - - A check has failed, it is not possible to update the object - - cmdbAbstractObject - - cmdbAbstractObject::DoCheckToWrite - - - Array of the issues (string) that prevented the object update - array - - - The object to check - DBObject - - - Debug string - string - - - - - An object is about to be updated in the database (no change possible) - - cmdbAbstractObject - - DBObject::OnUpdate - - - The object updated - DBObject - - - Debug string - string - - - An object has been updated into the database and reloaded. @@ -402,23 +291,6 @@ - - An object is about to be deleted in the database - - cmdbAbstractObject - - DBObject::OnDelete - - - The object deleted - DBObject - - - Debug string - string - - - An object has been deleted into the database diff --git a/core/dbobject.class.php b/core/dbobject.class.php index ebd2d317c..7edc82d23 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -2361,11 +2361,7 @@ abstract class DBObject implements iDisplay // Ultimate check - ensure DB integrity $this->SetReadOnly('No modification allowed during CheckToCreate'); - if ($this->IsNew()) { - $this->EventCheckToCreate(); - } else { - $this->EventCheckToUpdate(); - } + $this->EventCheckToWrite(); $this->SetReadWrite(); $this->DoCheckToWrite(); @@ -2377,11 +2373,7 @@ abstract class DBObject implements iDisplay else { $this->m_bCheckStatus = false; - if ($this->IsNew()) { - $this->EventCheckToCreateFailed($this->m_aCheckIssues); - } else { - $this->EventCheckToUpdateFailed($this->m_aCheckIssues); - } + $this->EventCheckToWriteFailed($this->m_aCheckIssues); } } return array($this->m_bCheckStatus, $this->m_aCheckIssues, $this->m_bSecurityIssue); @@ -2978,7 +2970,6 @@ abstract class DBObject implements iDisplay // Ensure the update of the values (we are accessing the data directly) $this->DoComputeValues(); - $this->EventCreateRequested(); $this->OnInsert(); if ($this->m_iKey < 0) { @@ -2999,10 +2990,6 @@ abstract class DBObject implements iDisplay } $this->ComputeStopWatchesDeadline(true); - $this->SetReadOnly('No modification allowed during The Event :'.EVENT_DB_ABOUT_TO_CREATE); - $this->EventAboutToCreate(); - $this->SetReadWrite(); - $iTransactionRetry = 1; $bIsTransactionEnabled = MetaModel::GetConfig()->Get('db_core_transactions_enabled'); if ($bIsTransactionEnabled) { @@ -3181,7 +3168,6 @@ abstract class DBObject implements iDisplay { $this->DoComputeValues(); $this->ComputeStopWatchesDeadline(false); - $this->EventUpdateRequested(); $this->OnUpdate(); // Freeze the changes at this point @@ -3233,9 +3219,6 @@ abstract class DBObject implements iDisplay $iIsTransactionRetryDelay = MetaModel::GetConfig()->Get('db_core_transactions_retry_delay_ms'); $iTransactionRetry = $iTransactionRetryCount; } - $this->SetReadOnly('No modification allowed during The Event :'.EVENT_DB_ABOUT_TO_UPDATE); - $this->EventAboutToUpdate(); - $this->SetReadWrite(); while ($iTransactionRetry > 0) { @@ -3614,7 +3597,6 @@ abstract class DBObject implements iDisplay return; } - $this->EventAboutToDelete(); $this->OnDelete(); // Activate any existing trigger @@ -5913,7 +5895,7 @@ abstract class DBObject implements iDisplay * @return void * @since 3.1.0 */ - protected function EventCreateRequested(): void + protected function EventCheckToWrite(): void { } @@ -5921,23 +5903,7 @@ abstract class DBObject implements iDisplay * @return void * @since 3.1.0 */ - protected function EventCheckToCreate(): void - { - } - - /** - * @return void - * @since 3.1.0 - */ - protected function EventCheckToCreateFailed(array $aIssues): void - { - } - - /** - * @return void - * @since 3.1.0 - */ - protected function EventAboutToCreate(): void + protected function EventCheckToWriteFailed(array $aIssues): void { } @@ -5953,38 +5919,6 @@ abstract class DBObject implements iDisplay /// UPDATE /// - /** - * @return void - * @since 3.1.0 - */ - protected function EventUpdateRequested(): void - { - } - - /** - * @return void - * @since 3.1.0 - */ - protected function EventCheckToUpdate(): void - { - } - - /** - * @return void - * @since 3.1.0 - */ - protected function EventCheckToUpdateFailed(array $aIssues): void - { - } - - /** - * @return void - * @since 3.1.0 - */ - protected function EventAboutToUpdate(): void - { - } - /** * @return void * @since 3.1.0 @@ -6013,14 +5947,6 @@ abstract class DBObject implements iDisplay { } - /** - * @return void - * @since 3.1.0 - */ - protected function EventAboutToDelete(): void - { - } - /** * @return void * @since 3.1.0