diff --git a/setup/applicationinstaller.class.inc.php b/setup/applicationinstaller.class.inc.php
index 77963a199..6f493e165 100644
--- a/setup/applicationinstaller.class.inc.php
+++ b/setup/applicationinstaller.class.inc.php
@@ -1002,6 +1002,7 @@ class SetupDBBackup extends DBBackup
class DataAuditSequencer extends ApplicationInstallSequencer
{
+ public const DATA_AUDIT_FAILED = 100;
protected function GetTempEnv()
@@ -1081,7 +1082,7 @@ class DataAuditSequencer extends ApplicationInstallSequencer
'message' => '',
'next-step' => 'write-config',
'next-step-label' => 'Writing audit config',
- 'percentage-completed' => 60,
+ 'percentage-completed' => 40,
];
break;
case 'write-config':
@@ -1091,7 +1092,7 @@ class DataAuditSequencer extends ApplicationInstallSequencer
'message' => '',
'next-step' => 'setup-audit',
'next-step-label' => 'Checking data consistency with the new data model',
- 'percentage-completed' => 70,
+ 'percentage-completed' => 60,
];
break;
case 'setup-audit':
@@ -1131,6 +1132,7 @@ class DataAuditSequencer extends ApplicationInstallSequencer
'next-step' => '',
'next-step-label' => '',
'percentage-completed' => 100,
+ 'error_code' => $e->getCode(),
];
SetupLog::Error('An exception occurred: '.$e->getMessage().' at line '.$e->getLine().' in file '.$e->getFile());
@@ -1181,15 +1183,13 @@ class DataAuditSequencer extends ApplicationInstallSequencer
$sTargetEnvironment = $this->GetTempEnv();
$sPreviousEnvironment = $this->GetTargetEnv();
-file_put_contents('C:/tmp/uninstall.log', "prev env=".$sPreviousEnvironment."\n", FILE_APPEND);
-file_put_contents('C:/tmp/uninstall.log', "target env=".$sTargetEnvironment."\n", FILE_APPEND);
$oSetupAudit = new SetupAudit($sPreviousEnvironment, $sTargetEnvironment);
$oSetupAudit->GetIssues(true);
$iCount = $oSetupAudit->GetDataToCleanupCount();
if ($iCount > 0) {
- throw new Exception("$iCount elements require data adjustments or cleanup in the backoffice prior to upgrading iTop");
+ throw new Exception("$iCount elements require data adjustments or cleanup in the backoffice prior to upgrading iTop", static::DATA_AUDIT_FAILED);
}
}
diff --git a/setup/feature_removal/ModelReflectionSerializer.php b/setup/feature_removal/ModelReflectionSerializer.php
index d3de6b9c9..9091ef3e4 100644
--- a/setup/feature_removal/ModelReflectionSerializer.php
+++ b/setup/feature_removal/ModelReflectionSerializer.php
@@ -46,7 +46,6 @@ class ModelReflectionSerializer
}
$aClasses = json_decode($sOutput[0] ?? null, true);
-file_put_contents('C:/tmp/uninstall.log', "\n\n".var_export($sOutput, true), FILE_APPEND);
if (false === $aClasses) {
$this->LogErrorWithProperLogger("Invalid JSON", null, ['env' => $sEnv, "output" => $sOutput]);
throw new Exception("cannot get classes");
diff --git a/setup/feature_removal/SetupAudit.php b/setup/feature_removal/SetupAudit.php
index ebad99527..b30b053ae 100644
--- a/setup/feature_removal/SetupAudit.php
+++ b/setup/feature_removal/SetupAudit.php
@@ -3,6 +3,7 @@
namespace Combodo\iTop\Setup\FeatureRemoval;
use MetaModel;
+use utils;
require_once __DIR__.'/AbstractSetupAudit.php';
require_once APPROOT.'setup/feature_removal/ModelReflectionSerializer.php';
@@ -28,14 +29,17 @@ class SetupAudit extends AbstractSetupAudit
return;
}
- $sCurrentEnvt = MetaModel::GetEnvironment();
- if ($sCurrentEnvt === $this->sEnvBefore) {
+ $sCurrentEnv = MetaModel::GetEnvironment();
+
+ $sConfFile = utils::GetConfigFilePath($sCurrentEnv);
+ MetaModel::Startup($sConfFile, false /* $bModelOnly */, false /* $bAllowCache */, false /* $bTraceSourceFiles */, $sCurrentEnv);
+ if ($sCurrentEnv === $this->sEnvBefore) {
$this->aClassesBefore = MetaModel::GetClasses();
} else {
$this->aClassesBefore = ModelReflectionSerializer::GetInstance()->GetModelFromEnvironment($this->sEnvBefore);
}
- if ($sCurrentEnvt === $this->sEnvAfter) {
+ if ($sCurrentEnv === $this->sEnvAfter) {
$this->aClassesAfter = MetaModel::GetClasses();
} else {
$this->aClassesAfter = ModelReflectionSerializer::GetInstance()->GetModelFromEnvironment($this->sEnvAfter);
diff --git a/setup/feature_removal/get_model_reflection.php b/setup/feature_removal/get_model_reflection.php
index e18925f63..7648b2c92 100644
--- a/setup/feature_removal/get_model_reflection.php
+++ b/setup/feature_removal/get_model_reflection.php
@@ -19,7 +19,7 @@ if (is_null($sEnv)) {
$sConfFile = utils::GetConfigFilePath($sEnv);
try {
- MetaModel::Startup($sConfFile, false /* $bModelOnly */, true /* $bAllowCache */, false /* $bTraceSourceFiles */, $sEnv);
+ MetaModel::Startup($sConfFile, false /* $bModelOnly */, false /* $bAllowCache */, false /* $bTraceSourceFiles */, $sEnv);
} catch (\Throwable $e) {
echo $e->getMessage();
echo $e->getTraceAsString();
diff --git a/setup/setup.js b/setup/setup.js
index a7d740260..c7917b749 100644
--- a/setup/setup.js
+++ b/setup/setup.js
@@ -25,21 +25,17 @@ function WizardAsyncAction(sActionCode, oParams, OnErrorFunction)
function WizardUpdateButtons()
{
- if (CanMoveForward())
- {
+ if (CanMoveForward()) {
$("#btn_next").prop('disabled', false);
}
- else
- {
+ else {
$("#btn_next").prop('disabled', true);
}
- if (CanMoveBackward())
- {
+ if (CanMoveBackward()) {
$("#btn_back").prop('disabled', false);
}
- else
- {
+ else {
$("#btn_back").prop('disabled', true);
}
}
diff --git a/setup/wizardsteps/WizStepDataAudit.php b/setup/wizardsteps/WizStepDataAudit.php
index df8527b8b..7bb62d0c2 100644
--- a/setup/wizardsteps/WizStepDataAudit.php
+++ b/setup/wizardsteps/WizStepDataAudit.php
@@ -73,6 +73,8 @@ class WizStepDataAudit extends WizStepInstall
$sAuthentToken = $this->oWizard->GetParameter('authent', '');
$oPage->add('');
+ $sApplicationUrl = $this->oWizard->GetParameter('application_url').'pages/UI.php';
+ $oPage->add('');
if (!$this->CheckDependencies()) {
$oPage->error($this->sDependencyIssue);
@@ -85,4 +87,31 @@ class WizStepDataAudit extends WizStepInstall
JS
);
}
+
+ protected function AddProgressErrorScript($oPage, $aRes){
+ if(isset($aRes['error_code']) && $aRes['error_code'] === DataAuditSequencer::DATA_AUDIT_FAILED){
+
+ $oPage->add_ready_script(
+ <<');
+
+ $('.ibo-setup--wizard--buttons-container tr td:nth-child(2)').after(' | ');
+
+ $("#wiz_form").data("installation_status", "cleanup_needed");
+ $('#btn_next').hide();
+EOF
+ );
+ }
+
+ }
+
+ public function JSCanMoveForward()
+ {
+ return 'return ["completed", "cleanup_needed"].indexOf($("#wiz_form").data("installation_status")) !== -1;';
+ }
+
+ public function JSCanMoveBackward()
+ {
+ return 'return ["not started", "error", "cleanup_needed"].indexOf($("#wiz_form").data("installation_status")) !== -1;';
+ }
}
diff --git a/setup/wizardsteps/WizStepInstall.php b/setup/wizardsteps/WizStepInstall.php
index fa4830238..4ab9cae86 100644
--- a/setup/wizardsteps/WizStepInstall.php
+++ b/setup/wizardsteps/WizStepInstall.php
@@ -63,6 +63,7 @@ class WizStepInstall extends AbstractWizStepInstall
$oPage->add('Ready to start...
0%
');
$oPage->add(''); // progress_content
$oPage->add('');
+ $oPage->add("");
}
@@ -77,7 +78,6 @@ class WizStepInstall extends AbstractWizStepInstall
$sAuthentToken = $this->oWizard->GetParameter('authent', '');
$oPage->add('');
-
if (!$this->CheckDependencies()) {
$oPage->error($this->sDependencyIssue);
}
@@ -128,18 +128,24 @@ EOF
EOF
);
} else {
+ //Error case
$sMessage = addslashes(utils::EscapeHtml($aRes['message']));
$sMessage = str_replace("\n", '
', $sMessage);
$oPage->add_ready_script(
<<AddProgressErrorScript($oPage, $aRes);
}
}
+ protected function AddProgressErrorScript($oPage, $aRes){
+
+ }
+
/**
* Tells whether the "Next" button should be enabled interactively
* @return string A piece of javascript code returning either true or false
diff --git a/setup/wizardsteps/WizStepSummary.php b/setup/wizardsteps/WizStepSummary.php
index 97d830451..30d2e8ad2 100644
--- a/setup/wizardsteps/WizStepSummary.php
+++ b/setup/wizardsteps/WizStepSummary.php
@@ -90,7 +90,7 @@ class WizStepSummary extends AbstractWizStepInstall
if (count($aExtensionsAdded) > 0) {
$sExtensionsAdded = '';
foreach ($aExtensionsAdded as $sExtensionCode => $sLabel) {
- $sExtensionsAdded .= "- $sLabel
'";
+ $sExtensionsAdded .= '- '.$sLabel.'
';
}
$sExtensionsAdded .= '
';
} else {
@@ -106,9 +106,9 @@ class WizStepSummary extends AbstractWizStepInstall
$sExtensionsRemoved = '';
foreach ($aExtensionsRemoved as $sExtensionCode => $sLabel) {
if (in_array($sExtensionCode, $aExtensionsNotUninstallable)) {
- $sExtensionsRemoved .= "- $sLabel (forced uninstallation)
";
+ $sExtensionsRemoved .= '- '.$sLabel.' (forced uninstallation)
';
} else {
- $sExtensionsRemoved .= "- $sLabel
";
+ $sExtensionsRemoved .= '- '.$sLabel.'
';
}
}
$sExtensionsRemoved .= '
';