N°9567 - Extension Mgmt : Run setup

This commit is contained in:
Eric Espie
2026-05-19 17:15:09 +02:00
parent 52bc9fcf14
commit 8f6e194855
7 changed files with 37 additions and 24 deletions

View File

@@ -10,7 +10,9 @@ namespace Combodo\iTop\DataFeatureRemoval\Controller;
require_once APPROOT.'setup/feature_removal/SetupAudit.php';
require_once APPROOT.'setup/feature_removal/DryRemovalRuntimeEnvironment.php';
use Combodo\iTop\Application\Helper\Session;
use Combodo\iTop\Application\TwigBase\Controller\Controller;
use Combodo\iTop\DataFeatureRemoval\Entity\DataCleanupSummaryEntity;
use Combodo\iTop\DataFeatureRemoval\Helper\DataFeatureRemovalException;
use Combodo\iTop\DataFeatureRemoval\Helper\DataFeatureRemovalHelper;
use Combodo\iTop\DataFeatureRemoval\Helper\DataFeatureRemovalLog;
@@ -133,7 +135,7 @@ class DataFeatureRemovalController extends Controller
$aParams['aAddedExtensions'] = $aAddedExtensions;
$aParams['aRemovedExtensions'] = $aRemovedExtensions;
IssueLog::Info(__METHOD__.' Extensions given in parameter', null, [
IssueLog::Debug(__METHOD__.' Extensions given in parameter', null, [
'added_extensions' => $aAddedExtensions,
'removed_extensions' => $aRemovedExtensions]);
@@ -159,6 +161,7 @@ class DataFeatureRemovalController extends Controller
[$aParams['aDeletionPlanSummary'], $aParams['iQueryCount'], $aParams['bDeletionPossible']] = $this->GetDeletionPlanSummaryTable($aGetRemovedClasses);
[$aParams['aDeletionExecutionSummary'], $aParams['bHasDeletionExecution']] = $this->GetExecutionSummaryTable();
$aParams['bDeletionNeeded'] = ($aParams['iQueryCount'] > 0);
Session::Set('aDeletionExecutionSummary', serialize($this->aDeletionExecutionSummary));
$this->DisplayPage($aParams, 'AnalysisResult');
}
@@ -174,7 +177,7 @@ class DataFeatureRemovalController extends Controller
if ($bIsDirEmpty || $bForceCompilation) {
$oRuntimeEnvironment = new DryRemovalRuntimeEnvironment($sSourceEnv, $aRemovedExtensions);
DataFeatureRemovalLog::Info(
DataFeatureRemovalLog::Debug(
__METHOD__,
null,
['sSourceEnv' => $sSourceEnv, 'sBuildDir' => $sBuildDir, 'bIsDirEmpty' => $bIsDirEmpty, glob("$sBuildDir/*")]
@@ -194,13 +197,14 @@ class DataFeatureRemovalController extends Controller
$aColumns = ['Class', 'Total Deleted Count' , 'Total Updated Count', 'Deleted Count' , 'Updated Count'];
$aRows = [];
foreach ($this->aDeletionExecutionSummary as $sClass => $oDeletionPlanSummaryEntity) {
/** @var DataCleanupSummaryEntity $oSummary */
foreach ($this->aDeletionExecutionSummary as $sClass => $oSummary) {
$aRows[] = [
$sClass,
$oDeletionPlanSummaryEntity->iTotalDeletedCount,
$oDeletionPlanSummaryEntity->iTotalUpdatedCount,
$oDeletionPlanSummaryEntity->iDeletedCount,
$oDeletionPlanSummaryEntity->iUpdatedCount,
$oSummary->iTotalDeleteCount,
$oSummary->iTotalUpdateCount,
$oSummary->iDeleteCount,
$oSummary->iUpdateCount,
];
}
@@ -237,10 +241,22 @@ class DataFeatureRemovalController extends Controller
{
$this->ValidateTransactionId();
$this->aDeletionExecutionSummary = unserialize(Session::Get('aDeletionExecutionSummary'));
Session::Unset('aDeletionExecutionSummary');
$aClasses = utils::ReadPostedParam('classes', null, utils::ENUM_SANITIZATION_FILTER_CLASS);
$oDataCleanupService = new DataCleanupService();
$this->aDeletionExecutionSummary = $oDataCleanupService->ExecuteCleanup($aClasses, $this->aDeletionExecutionSummary);
$aDeletionExecutionSummary = $oDataCleanupService->ExecuteCleanup($aClasses);
foreach ($aDeletionExecutionSummary as $sClass => $oExecutionSummary) {
if (!array_key_exists($sClass, $this->aDeletionExecutionSummary)) {
$this->aDeletionExecutionSummary[$sClass] = new DataCleanupSummaryEntity($sClass);
}
$oSummary = $this->aDeletionExecutionSummary[$sClass];
$oSummary->iDeleteCount = $oExecutionSummary->iDeleteCount;
$oSummary->iUpdateCount = $oExecutionSummary->iUpdateCount;
$oSummary->iTotalDeleteCount += $oExecutionSummary->iDeleteCount;
$oSummary->iTotalUpdateCount += $oExecutionSummary->iUpdateCount;
}
$this->OperationAnalysisResult();
}

View File

@@ -35,7 +35,7 @@ class DataCleanupService
*/
public function GetCleanupSummary(?array $aClasses): array
{
return $this->ExecuteCleanup($aClasses ?? [], [], oObjectService: new ObjectServiceSummary());
return $this->ExecuteCleanup($aClasses ?? [], oObjectService: new ObjectServiceSummary());
}
private function GetNextObjectToDelete(array $aClasses): ?DBObject
@@ -56,7 +56,6 @@ class DataCleanupService
/**
* @param array $aClasses
* @param array $aPreviousExecutionSummary
* @param \Combodo\iTop\DataFeatureRemoval\Service\iObjectService|null $oObjectService
*
* @return array execution summary
@@ -66,10 +65,9 @@ class DataCleanupService
* @throws \CoreUnexpectedValue
* @throws \MySQLException
*/
public function ExecuteCleanup(array $aClasses, array $aPreviousExecutionSummary, ?iObjectService $oObjectService = null): array
public function ExecuteCleanup(array $aClasses, ?iObjectService $oObjectService = null): array
{
$this->oObjectService = $oObjectService ?? new ObjectService();
$this->oObjectService->SetSummary($aPreviousExecutionSummary);
$this->aVisited = [];

View File

@@ -60,7 +60,6 @@ class ObjectServiceSummary implements iObjectService
public function SetSummary(array $aSummary): void
{
$this->aSummary = [];
foreach ($aSummary as $sClass => $oPreviousSummaryEntity) {
$oSummaryEntity = new DataCleanupSummaryEntity($sClass);
$oSummaryEntity->iTotalUpdateCount = $oPreviousSummaryEntity->iTotalUpdateCount;

View File

@@ -170,7 +170,7 @@ class iTopExtensionsMap
foreach ($oExtension->aModules as $sModuleName) {
$aCurrentModuleConfig = $aModuleConfigs[$sModuleName] ?? null;
if (is_null($aCurrentModuleConfig)) {
IssueLog::Info("Installation choice comes with missing module file", null, ["choice" => $oExtension->sCode, 'module' => $sModuleName]);
IssueLog::Debug("Installation choice comes with missing module file", null, ["choice" => $oExtension->sCode, 'module' => $sModuleName]);
continue;
}
$oExtension->aModuleVersion[$sModuleName] = $aCurrentModuleConfig['module_version'];
@@ -256,7 +256,7 @@ class iTopExtensionsMap
$oExtension = $this->GetFromExtensionCode($sCode);
if (!is_null($oExtension)) {
$aRemovedExtension [] = $oExtension;
\IssueLog::Info(__METHOD__.": remove extension locally", null, ['extension_code' => $oExtension->sCode]);
\IssueLog::Debug(__METHOD__.": remove extension locally", null, ['extension_code' => $oExtension->sCode]);
} else {
\IssueLog::Warning(__METHOD__." cannot find extensions", null, ['code' => $sCode]);
}

View File

@@ -107,7 +107,7 @@ abstract class AbstractSetupAudit
if (ContextTag::Check(ContextTag::TAG_SETUP)) {
SetupLog::Info($sMessage, $sChannel, $aContext);
} else {
IssueLog::Info($sMessage, $sChannel, $aContext);
IssueLog::Debug($sMessage, $sChannel, $aContext);
}
}
}

View File

@@ -427,13 +427,13 @@ class ModuleDiscovery
continue;
}
IssueLog::Info("Module considered as removed", null, ['extension_code' => $oExtension->sCode, 'module_name' => $sModuleName, 'module_version' => $sModuleVersion, ModuleFileReader::MODULE_FILE_PATH => $sCurrentModuleFilePath]);
IssueLog::Debug("Module considered as removed", null, ['extension_code' => $oExtension->sCode, 'module_name' => $sModuleName, 'module_version' => $sModuleVersion, ModuleFileReader::MODULE_FILE_PATH => $sCurrentModuleFilePath]);
return true;
}
if (count($aNonMatchingPaths) > 0) {
//add log for support
IssueLog::Info("Module kept as it came from non removed extensions", null, ['module_name' => $sModuleName, 'module_version' => $sModuleVersion, ModuleFileReader::MODULE_FILE_PATH => $sModuleFilePath, 'non_matching_paths' => $aNonMatchingPaths]);
IssueLog::Debug("Module kept as it came from non removed extensions", null, ['module_name' => $sModuleName, 'module_version' => $sModuleVersion, ModuleFileReader::MODULE_FILE_PATH => $sModuleFilePath, 'non_matching_paths' => $aNonMatchingPaths]);
}
IssueLog::Debug(__METHOD__.' Module loaded', null, ['name' => $sModuleName, 'version' => $sModuleVersion]);
return false;

View File

@@ -69,7 +69,7 @@ class DataCleanupServiceTest extends ItopCustomDatamodelTestCase
$aClasses = [ 'DFRToRemoveLeaf' ];
$oService = new DataCleanupService();
$aRes = $oService->ExecuteCleanup($aClasses, []);
$aRes = $oService->ExecuteCleanup($aClasses);
$aExpected = [
['DFRToUpdate', 1, 0 ],
['DFRToRemoveLeaf', 0, 1 ],
@@ -97,7 +97,7 @@ class DataCleanupServiceTest extends ItopCustomDatamodelTestCase
$aClasses = [ 'DFRToRemoveLeaf' ];
$oService = new DataCleanupService();
$aRes = $oService->ExecuteCleanup($aClasses, []);
$aRes = $oService->ExecuteCleanup($aClasses);
$aExpected = [
['DFRToUpdate', 3, 0 ],
['DFRToRemoveLeaf', 0, 3 ],
@@ -129,7 +129,7 @@ class DataCleanupServiceTest extends ItopCustomDatamodelTestCase
$aClasses = ['DFRToRemoveLeaf'];
$oService = new DataCleanupService();
$aExecutionSummary = $oService->ExecuteCleanup($aClasses, $aExecutionSummary);
$aExecutionSummary = $oService->ExecuteCleanup($aClasses);
$aExpected = [
['DFRToUpdate', 3, 0 ],
@@ -149,7 +149,7 @@ class DataCleanupServiceTest extends ItopCustomDatamodelTestCase
$aClasses = ['DFRToRemoveLeaf'];
$oService = new DataCleanupService();
$aExecutionSummary = $oService->ExecuteCleanup($aClasses, $aExecutionSummary);
$aExecutionSummary = $oService->ExecuteCleanup($aClasses);
$aExpected = [
['DFRToUpdate', 1, 0, 0, 4 ],
@@ -198,7 +198,7 @@ class DataCleanupServiceTest extends ItopCustomDatamodelTestCase
$this->expectException(DataFeatureRemovalException::class);
$this->expectExceptionMessage('Deletion Plan cannot be executed due to issues');
$oService = new DataCleanupService();
$oService->ExecuteCleanup($aClasses, []);
$oService->ExecuteCleanup($aClasses);
}
public function testGetCleanupSummary_ManualDeleteShouldFail()
@@ -310,7 +310,7 @@ class DataCleanupServiceTest extends ItopCustomDatamodelTestCase
$oDeletionPlaService = new DataCleanupService();
$this->GivenExecutionLimits($iExecutionCount);
$this->SetNonPublicProperty($oDeletionPlaService, 'oExecutionLimits', $this->oExecutionLimits);
$aRes = $oDeletionPlaService->ExecuteCleanup($aClasses, []);
$aRes = $oDeletionPlaService->ExecuteCleanup($aClasses);
$this->AssertSummaryEquals($aExpected, $aRes);
}