diff --git a/datamodels/2.x/combodo-data-feature-removal/src/Service/DeletionPlanService.php b/datamodels/2.x/combodo-data-feature-removal/src/Service/DeletionPlanService.php index 4e123f812b..5aa49e43cb 100644 --- a/datamodels/2.x/combodo-data-feature-removal/src/Service/DeletionPlanService.php +++ b/datamodels/2.x/combodo-data-feature-removal/src/Service/DeletionPlanService.php @@ -2,6 +2,7 @@ namespace Combodo\iTop\DataFeatureRemoval\Service; +use CMDBSource; use Combodo\iTop\DataFeatureRemoval\Entity\DeletionPlanSummaryEntity; use Combodo\iTop\DataFeatureRemoval\Helper\DataFeatureRemovalException; use DBObjectSearch; @@ -139,7 +140,6 @@ class DeletionPlanService foreach ($aData['attributes'] as $sRemoteExtKey => $aRemoteAttDef) { $oToUpdate->Set($sRemoteExtKey, 0); $oToUpdate->DBUpdate(); - $oDeletionPlanSummaryEntity->iUpdateCount++; } } @@ -158,10 +158,11 @@ class DeletionPlanService MetaModel::PurgeData($oFilter); // Delete the entry - foreach (\MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_ALL, false) as $sParentClass) { - $oFilter = \DBObjectSearch::FromOQL_AllData("SELECT $sParentClass WHERE id=:id"); + $aClassesToRemove = array_merge(MetaModel::EnumChildClasses($sClass, ENUM_PARENT_CLASSES_ALL), MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_EXCLUDELEAF, false)); + foreach ($aClassesToRemove as $sParentClass) { + $oFilter = DBObjectSearch::FromOQL_AllData("SELECT $sParentClass WHERE id=:id"); $sQuery = $oFilter->MakeDeleteQuery(['id' => $sId]); - \CMDBSource::DeleteFrom($sQuery); + CMDBSource::DeleteFrom($sQuery); } $oDeletionPlanSummaryEntity->iDeleteCount++;