N°8764 - stop setup and display data to cleanup message

This commit is contained in:
odain
2026-01-09 14:52:00 +01:00
parent 43bd621731
commit 0996e8fae0
2 changed files with 42 additions and 13 deletions

View File

@@ -2,9 +2,12 @@
namespace Combodo\iTop\Setup\FeatureRemoval;
use ContextTag;
use DBObjectSearch;
use DBObjectSet;
use IssueLog;
use MetaModel;
use SetupLog;
require_once APPROOT.'setup/feature_removal/ModelReflectionSerializer.php';
@@ -121,14 +124,25 @@ class SetupAudit
$this->aFinalClassesRemoved[$sClass] = $iCount;
if ($bThrowExceptionAtFirstIssue && $iCount > 0) {
//setup envt: should raise issue ASAP
$this->LogInfoWithProperLogger("Setup audit found data to cleanup", null, $this->aFinalClassesRemoved);
throw new \Exception($sClass);
}
}
}
$this->LogInfoWithProperLogger("Setup audit found data to cleanup", null, $this->aFinalClassesRemoved);
return $this->aFinalClassesRemoved;
}
public function GetLastComputedFinalClassesRemovedCount(): int
{
$res = 0;
foreach ($this->aFinalClassesRemoved as $sClass => $iCount) {
$res += $iCount;
}
return $res;
}
private function Count($sClass): int
{
$oSearch = DBObjectSearch::FromOQL("SELECT $sClass", []);
@@ -137,4 +151,14 @@ class SetupAudit
return $oSet->Count();
}
//could be shared with others in log APIs ?
private function LogInfoWithProperLogger($sMessage, $sChannel = null, $aContext = []): void
{
if (ContextTag::Check(ContextTag::TAG_SETUP)) {
SetupLog::Info($sMessage, $sChannel, $aContext);
} else {
IssueLog::Info($sMessage, $sChannel, $aContext);
}
}
}