mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-20 07:42:17 +02:00
N°9567 - Extension Mgmt : Run setup
This commit is contained in:
@@ -10,7 +10,9 @@ namespace Combodo\iTop\DataFeatureRemoval\Controller;
|
|||||||
require_once APPROOT.'setup/feature_removal/SetupAudit.php';
|
require_once APPROOT.'setup/feature_removal/SetupAudit.php';
|
||||||
require_once APPROOT.'setup/feature_removal/DryRemovalRuntimeEnvironment.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\Application\TwigBase\Controller\Controller;
|
||||||
|
use Combodo\iTop\DataFeatureRemoval\Entity\DataCleanupSummaryEntity;
|
||||||
use Combodo\iTop\DataFeatureRemoval\Helper\DataFeatureRemovalException;
|
use Combodo\iTop\DataFeatureRemoval\Helper\DataFeatureRemovalException;
|
||||||
use Combodo\iTop\DataFeatureRemoval\Helper\DataFeatureRemovalHelper;
|
use Combodo\iTop\DataFeatureRemoval\Helper\DataFeatureRemovalHelper;
|
||||||
use Combodo\iTop\DataFeatureRemoval\Helper\DataFeatureRemovalLog;
|
use Combodo\iTop\DataFeatureRemoval\Helper\DataFeatureRemovalLog;
|
||||||
@@ -133,7 +135,7 @@ class DataFeatureRemovalController extends Controller
|
|||||||
$aParams['aAddedExtensions'] = $aAddedExtensions;
|
$aParams['aAddedExtensions'] = $aAddedExtensions;
|
||||||
$aParams['aRemovedExtensions'] = $aRemovedExtensions;
|
$aParams['aRemovedExtensions'] = $aRemovedExtensions;
|
||||||
|
|
||||||
IssueLog::Info(__METHOD__.' Extensions given in parameter', null, [
|
IssueLog::Debug(__METHOD__.' Extensions given in parameter', null, [
|
||||||
'added_extensions' => $aAddedExtensions,
|
'added_extensions' => $aAddedExtensions,
|
||||||
'removed_extensions' => $aRemovedExtensions]);
|
'removed_extensions' => $aRemovedExtensions]);
|
||||||
|
|
||||||
@@ -159,6 +161,7 @@ class DataFeatureRemovalController extends Controller
|
|||||||
[$aParams['aDeletionPlanSummary'], $aParams['iQueryCount'], $aParams['bDeletionPossible']] = $this->GetDeletionPlanSummaryTable($aGetRemovedClasses);
|
[$aParams['aDeletionPlanSummary'], $aParams['iQueryCount'], $aParams['bDeletionPossible']] = $this->GetDeletionPlanSummaryTable($aGetRemovedClasses);
|
||||||
[$aParams['aDeletionExecutionSummary'], $aParams['bHasDeletionExecution']] = $this->GetExecutionSummaryTable();
|
[$aParams['aDeletionExecutionSummary'], $aParams['bHasDeletionExecution']] = $this->GetExecutionSummaryTable();
|
||||||
$aParams['bDeletionNeeded'] = ($aParams['iQueryCount'] > 0);
|
$aParams['bDeletionNeeded'] = ($aParams['iQueryCount'] > 0);
|
||||||
|
Session::Set('aDeletionExecutionSummary', serialize($this->aDeletionExecutionSummary));
|
||||||
|
|
||||||
$this->DisplayPage($aParams, 'AnalysisResult');
|
$this->DisplayPage($aParams, 'AnalysisResult');
|
||||||
}
|
}
|
||||||
@@ -174,7 +177,7 @@ class DataFeatureRemovalController extends Controller
|
|||||||
|
|
||||||
if ($bIsDirEmpty || $bForceCompilation) {
|
if ($bIsDirEmpty || $bForceCompilation) {
|
||||||
$oRuntimeEnvironment = new DryRemovalRuntimeEnvironment($sSourceEnv, $aRemovedExtensions);
|
$oRuntimeEnvironment = new DryRemovalRuntimeEnvironment($sSourceEnv, $aRemovedExtensions);
|
||||||
DataFeatureRemovalLog::Info(
|
DataFeatureRemovalLog::Debug(
|
||||||
__METHOD__,
|
__METHOD__,
|
||||||
null,
|
null,
|
||||||
['sSourceEnv' => $sSourceEnv, 'sBuildDir' => $sBuildDir, 'bIsDirEmpty' => $bIsDirEmpty, glob("$sBuildDir/*")]
|
['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'];
|
$aColumns = ['Class', 'Total Deleted Count' , 'Total Updated Count', 'Deleted Count' , 'Updated Count'];
|
||||||
$aRows = [];
|
$aRows = [];
|
||||||
foreach ($this->aDeletionExecutionSummary as $sClass => $oDeletionPlanSummaryEntity) {
|
/** @var DataCleanupSummaryEntity $oSummary */
|
||||||
|
foreach ($this->aDeletionExecutionSummary as $sClass => $oSummary) {
|
||||||
$aRows[] = [
|
$aRows[] = [
|
||||||
$sClass,
|
$sClass,
|
||||||
$oDeletionPlanSummaryEntity->iTotalDeletedCount,
|
$oSummary->iTotalDeleteCount,
|
||||||
$oDeletionPlanSummaryEntity->iTotalUpdatedCount,
|
$oSummary->iTotalUpdateCount,
|
||||||
$oDeletionPlanSummaryEntity->iDeletedCount,
|
$oSummary->iDeleteCount,
|
||||||
$oDeletionPlanSummaryEntity->iUpdatedCount,
|
$oSummary->iUpdateCount,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,10 +241,22 @@ class DataFeatureRemovalController extends Controller
|
|||||||
{
|
{
|
||||||
$this->ValidateTransactionId();
|
$this->ValidateTransactionId();
|
||||||
|
|
||||||
|
$this->aDeletionExecutionSummary = unserialize(Session::Get('aDeletionExecutionSummary'));
|
||||||
|
Session::Unset('aDeletionExecutionSummary');
|
||||||
$aClasses = utils::ReadPostedParam('classes', null, utils::ENUM_SANITIZATION_FILTER_CLASS);
|
$aClasses = utils::ReadPostedParam('classes', null, utils::ENUM_SANITIZATION_FILTER_CLASS);
|
||||||
|
|
||||||
$oDataCleanupService = new DataCleanupService();
|
$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();
|
$this->OperationAnalysisResult();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class DataCleanupService
|
|||||||
*/
|
*/
|
||||||
public function GetCleanupSummary(?array $aClasses): array
|
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
|
private function GetNextObjectToDelete(array $aClasses): ?DBObject
|
||||||
@@ -56,7 +56,6 @@ class DataCleanupService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $aClasses
|
* @param array $aClasses
|
||||||
* @param array $aPreviousExecutionSummary
|
|
||||||
* @param \Combodo\iTop\DataFeatureRemoval\Service\iObjectService|null $oObjectService
|
* @param \Combodo\iTop\DataFeatureRemoval\Service\iObjectService|null $oObjectService
|
||||||
*
|
*
|
||||||
* @return array execution summary
|
* @return array execution summary
|
||||||
@@ -66,10 +65,9 @@ class DataCleanupService
|
|||||||
* @throws \CoreUnexpectedValue
|
* @throws \CoreUnexpectedValue
|
||||||
* @throws \MySQLException
|
* @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 = $oObjectService ?? new ObjectService();
|
||||||
$this->oObjectService->SetSummary($aPreviousExecutionSummary);
|
|
||||||
|
|
||||||
$this->aVisited = [];
|
$this->aVisited = [];
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ class ObjectServiceSummary implements iObjectService
|
|||||||
|
|
||||||
public function SetSummary(array $aSummary): void
|
public function SetSummary(array $aSummary): void
|
||||||
{
|
{
|
||||||
$this->aSummary = [];
|
|
||||||
foreach ($aSummary as $sClass => $oPreviousSummaryEntity) {
|
foreach ($aSummary as $sClass => $oPreviousSummaryEntity) {
|
||||||
$oSummaryEntity = new DataCleanupSummaryEntity($sClass);
|
$oSummaryEntity = new DataCleanupSummaryEntity($sClass);
|
||||||
$oSummaryEntity->iTotalUpdateCount = $oPreviousSummaryEntity->iTotalUpdateCount;
|
$oSummaryEntity->iTotalUpdateCount = $oPreviousSummaryEntity->iTotalUpdateCount;
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ class iTopExtensionsMap
|
|||||||
foreach ($oExtension->aModules as $sModuleName) {
|
foreach ($oExtension->aModules as $sModuleName) {
|
||||||
$aCurrentModuleConfig = $aModuleConfigs[$sModuleName] ?? null;
|
$aCurrentModuleConfig = $aModuleConfigs[$sModuleName] ?? null;
|
||||||
if (is_null($aCurrentModuleConfig)) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
$oExtension->aModuleVersion[$sModuleName] = $aCurrentModuleConfig['module_version'];
|
$oExtension->aModuleVersion[$sModuleName] = $aCurrentModuleConfig['module_version'];
|
||||||
@@ -256,7 +256,7 @@ class iTopExtensionsMap
|
|||||||
$oExtension = $this->GetFromExtensionCode($sCode);
|
$oExtension = $this->GetFromExtensionCode($sCode);
|
||||||
if (!is_null($oExtension)) {
|
if (!is_null($oExtension)) {
|
||||||
$aRemovedExtension [] = $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 {
|
} else {
|
||||||
\IssueLog::Warning(__METHOD__." cannot find extensions", null, ['code' => $sCode]);
|
\IssueLog::Warning(__METHOD__." cannot find extensions", null, ['code' => $sCode]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ abstract class AbstractSetupAudit
|
|||||||
if (ContextTag::Check(ContextTag::TAG_SETUP)) {
|
if (ContextTag::Check(ContextTag::TAG_SETUP)) {
|
||||||
SetupLog::Info($sMessage, $sChannel, $aContext);
|
SetupLog::Info($sMessage, $sChannel, $aContext);
|
||||||
} else {
|
} else {
|
||||||
IssueLog::Info($sMessage, $sChannel, $aContext);
|
IssueLog::Debug($sMessage, $sChannel, $aContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -427,13 +427,13 @@ class ModuleDiscovery
|
|||||||
continue;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($aNonMatchingPaths) > 0) {
|
if (count($aNonMatchingPaths) > 0) {
|
||||||
//add log for support
|
//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]);
|
IssueLog::Debug(__METHOD__.' Module loaded', null, ['name' => $sModuleName, 'version' => $sModuleVersion]);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class DataCleanupServiceTest extends ItopCustomDatamodelTestCase
|
|||||||
|
|
||||||
$aClasses = [ 'DFRToRemoveLeaf' ];
|
$aClasses = [ 'DFRToRemoveLeaf' ];
|
||||||
$oService = new DataCleanupService();
|
$oService = new DataCleanupService();
|
||||||
$aRes = $oService->ExecuteCleanup($aClasses, []);
|
$aRes = $oService->ExecuteCleanup($aClasses);
|
||||||
$aExpected = [
|
$aExpected = [
|
||||||
['DFRToUpdate', 1, 0 ],
|
['DFRToUpdate', 1, 0 ],
|
||||||
['DFRToRemoveLeaf', 0, 1 ],
|
['DFRToRemoveLeaf', 0, 1 ],
|
||||||
@@ -97,7 +97,7 @@ class DataCleanupServiceTest extends ItopCustomDatamodelTestCase
|
|||||||
|
|
||||||
$aClasses = [ 'DFRToRemoveLeaf' ];
|
$aClasses = [ 'DFRToRemoveLeaf' ];
|
||||||
$oService = new DataCleanupService();
|
$oService = new DataCleanupService();
|
||||||
$aRes = $oService->ExecuteCleanup($aClasses, []);
|
$aRes = $oService->ExecuteCleanup($aClasses);
|
||||||
$aExpected = [
|
$aExpected = [
|
||||||
['DFRToUpdate', 3, 0 ],
|
['DFRToUpdate', 3, 0 ],
|
||||||
['DFRToRemoveLeaf', 0, 3 ],
|
['DFRToRemoveLeaf', 0, 3 ],
|
||||||
@@ -129,7 +129,7 @@ class DataCleanupServiceTest extends ItopCustomDatamodelTestCase
|
|||||||
|
|
||||||
$aClasses = ['DFRToRemoveLeaf'];
|
$aClasses = ['DFRToRemoveLeaf'];
|
||||||
$oService = new DataCleanupService();
|
$oService = new DataCleanupService();
|
||||||
$aExecutionSummary = $oService->ExecuteCleanup($aClasses, $aExecutionSummary);
|
$aExecutionSummary = $oService->ExecuteCleanup($aClasses);
|
||||||
|
|
||||||
$aExpected = [
|
$aExpected = [
|
||||||
['DFRToUpdate', 3, 0 ],
|
['DFRToUpdate', 3, 0 ],
|
||||||
@@ -149,7 +149,7 @@ class DataCleanupServiceTest extends ItopCustomDatamodelTestCase
|
|||||||
|
|
||||||
$aClasses = ['DFRToRemoveLeaf'];
|
$aClasses = ['DFRToRemoveLeaf'];
|
||||||
$oService = new DataCleanupService();
|
$oService = new DataCleanupService();
|
||||||
$aExecutionSummary = $oService->ExecuteCleanup($aClasses, $aExecutionSummary);
|
$aExecutionSummary = $oService->ExecuteCleanup($aClasses);
|
||||||
|
|
||||||
$aExpected = [
|
$aExpected = [
|
||||||
['DFRToUpdate', 1, 0, 0, 4 ],
|
['DFRToUpdate', 1, 0, 0, 4 ],
|
||||||
@@ -198,7 +198,7 @@ class DataCleanupServiceTest extends ItopCustomDatamodelTestCase
|
|||||||
$this->expectException(DataFeatureRemovalException::class);
|
$this->expectException(DataFeatureRemovalException::class);
|
||||||
$this->expectExceptionMessage('Deletion Plan cannot be executed due to issues');
|
$this->expectExceptionMessage('Deletion Plan cannot be executed due to issues');
|
||||||
$oService = new DataCleanupService();
|
$oService = new DataCleanupService();
|
||||||
$oService->ExecuteCleanup($aClasses, []);
|
$oService->ExecuteCleanup($aClasses);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetCleanupSummary_ManualDeleteShouldFail()
|
public function testGetCleanupSummary_ManualDeleteShouldFail()
|
||||||
@@ -310,7 +310,7 @@ class DataCleanupServiceTest extends ItopCustomDatamodelTestCase
|
|||||||
$oDeletionPlaService = new DataCleanupService();
|
$oDeletionPlaService = new DataCleanupService();
|
||||||
$this->GivenExecutionLimits($iExecutionCount);
|
$this->GivenExecutionLimits($iExecutionCount);
|
||||||
$this->SetNonPublicProperty($oDeletionPlaService, 'oExecutionLimits', $this->oExecutionLimits);
|
$this->SetNonPublicProperty($oDeletionPlaService, 'oExecutionLimits', $this->oExecutionLimits);
|
||||||
$aRes = $oDeletionPlaService->ExecuteCleanup($aClasses, []);
|
$aRes = $oDeletionPlaService->ExecuteCleanup($aClasses);
|
||||||
$this->AssertSummaryEquals($aExpected, $aRes);
|
$this->AssertSummaryEquals($aExpected, $aRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user