From dc3f6a9f7272ac338b4d6a40e01eb876c1d5000b Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Thu, 25 Jun 2026 17:20:17 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B09639=20-=20Refactor=20data=20feature=20r?= =?UTF-8?q?emoval=20logic=20and=20update=20database=20queries=20for=20cons?= =?UTF-8?q?istency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataFeatureRemovalController.php | 1 + .../src/Service/StaticDeletionPlan.php | 31 +++++++++---------- .../unattended-install/xml_setup/upgrade.xml | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/datamodels/2.x/combodo-data-feature-removal/src/Controller/DataFeatureRemovalController.php b/datamodels/2.x/combodo-data-feature-removal/src/Controller/DataFeatureRemovalController.php index 28065f2cdd..248b7bc1d6 100644 --- a/datamodels/2.x/combodo-data-feature-removal/src/Controller/DataFeatureRemovalController.php +++ b/datamodels/2.x/combodo-data-feature-removal/src/Controller/DataFeatureRemovalController.php @@ -224,6 +224,7 @@ class DataFeatureRemovalController extends Controller $bIsDirEmpty = count(scandir($sBuildDir)) === 2; if ($bIsDirEmpty || $bForceCompilation) { + Session::Unset('bForceCompilation'); DataFeatureRemovalLog::Debug( __METHOD__, null, diff --git a/datamodels/2.x/combodo-data-feature-removal/src/Service/StaticDeletionPlan.php b/datamodels/2.x/combodo-data-feature-removal/src/Service/StaticDeletionPlan.php index df178b9b98..2283e0e465 100644 --- a/datamodels/2.x/combodo-data-feature-removal/src/Service/StaticDeletionPlan.php +++ b/datamodels/2.x/combodo-data-feature-removal/src/Service/StaticDeletionPlan.php @@ -26,9 +26,6 @@ class StaticDeletionPlan * * @return array<\Combodo\iTop\DataFeatureRemoval\Entity\DataCleanupSummaryEntity> * @throws \CoreException - * @throws \CoreUnexpectedValue - * @throws \MySQLException - * @throws \Combodo\iTop\DataFeatureRemoval\Helper\DataFeatureRemovalException */ public function GetCleanupSummary(?array $aClasses): array { @@ -160,21 +157,21 @@ SQL; */ public function UpdateHierarchicalExtKey(string $sRemoteClass, string $sExtKeyAttCode, string $sIdsToRemoveInTargetClass): DeletionPlanItem { - [$sDBTable, $sDBField] = $this->GetDBInfoForAttcode($sRemoteClass, $sExtKeyAttCode); + [$sDBTable, $sDBField, $sDBKey] = $this->GetDBInfoForAttcode($sRemoteClass, $sExtKeyAttCode); $sUpdateSQL = << $sUpdateSQL], $aIds); } @@ -193,10 +190,10 @@ SQL; if (\utils::IsNullOrEmptyString($sIdsToRemoveInTargetClass)) { return []; } - [$sDBTable, $sDBField] = $this->GetDBInfoForAttcode($sRemoteClass, $sExtKeyAttCode); - $sSQL = "SELECT id FROM $sDBTable WHERE $sDBField IN ($sIdsToRemoveInTargetClass)"; + [$sDBTable, $sDBField, $sDBKey] = $this->GetDBInfoForAttcode($sRemoteClass, $sExtKeyAttCode); + $sSQL = "SELECT $sDBKey FROM $sDBTable WHERE $sDBField IN ($sIdsToRemoveInTargetClass)"; - return CMDBSource::QueryToCol($sSQL, 'id'); + return CMDBSource::QueryToCol($sSQL, $sDBKey); } /** @@ -209,8 +206,9 @@ SQL; public function GetInitialClassDeletionPlan(string $sClass): DeletionPlanItem { $sTable = MetaModel::DBGetTable($sClass); - $sSQL = "SELECT id FROM $sTable"; - $aIds = CMDBSource::QueryToCol($sSQL, 'id'); + $sDBKey = MetaModel::DBGetKey($sClass); + $sSQL = "SELECT $sDBKey FROM $sTable"; + $aIds = CMDBSource::QueryToCol($sSQL, $sDBKey); $sDeleteSQL = "DELETE FROM $sTable"; return new DeletionPlanItem([$sDeleteSQL], $aIds); @@ -232,7 +230,8 @@ SQL; $sRealTable = MetaModel::DBGetTable($sRealClass); $oAttDef = MetaModel::GetAttributeDef($sRealClass, $sExtKeyAttCode); $sSQLAttCode = array_keys($oAttDef->GetSQLColumns())[0]; - return [$sRealTable, $sSQLAttCode]; + $sDBKey = MetaModel::DBGetKey($sRemoteClass); + return [$sRealTable, $sSQLAttCode, $sDBKey]; } } diff --git a/setup/unattended-install/xml_setup/upgrade.xml b/setup/unattended-install/xml_setup/upgrade.xml index bef34398af..0272bd2551 100644 --- a/setup/unattended-install/xml_setup/upgrade.xml +++ b/setup/unattended-install/xml_setup/upgrade.xml @@ -41,5 +41,5 @@ - on + off