N°2684 Remove upgrade from another repository

This upgrade procedure was :
* dangerous : running two iTop of different versions on the same database should not be done
* insufficient : just /extensions/* was copied, not any Hub or Designer data, no log, no instance.txt, ...
This commit is contained in:
Pierre Goiffon
2020-02-25 17:09:47 +01:00
parent 2f920cbb46
commit beef2a89a3

View File

@@ -267,12 +267,20 @@ class WizStepInstallOrUpgrade extends WizardStep
$sChecked = ($sInstallMode == 'install') ? ' checked ' : '';
$oPage->p('<input id="radio_install" type="radio" name="install_mode" value="install" '.$sChecked.'/><label for="radio_install">&nbsp;Install a new '.ITOP_APPLICATION.'</label>');
$sChecked = ($sInstallMode == 'upgrade') ? ' checked ' : '';
$oPage->p('<input id="radio_update" type="radio" name="install_mode" value="upgrade" '.$sChecked.'/><label for="radio_update">&nbsp;Upgrade an existing '.ITOP_APPLICATION.' instance</label>');
//$oPage->add('<fieldset id="upgrade_info"'.$sUpgradeInfoStyle.'>');
//$oPage->add('<legend>Information about the previous instance:</legend>');
$oPage->add('<table id="upgrade_info"'.$sUpgradeInfoStyle.'>');
$oPage->add('<tr><td>Location on the disk:</td><td><input id="previous_version_dir" type="text" name="previous_version_dir" value="'.htmlentities($sPreviousVersionDir,
ENT_QUOTES, 'UTF-8').'" style="width: 98%;"/></td></tr>');
$sDisabled = (($sInstallMode == 'install') && (empty($sPreviousVersionDir))) ? ' disabled' : '';
$oPage->p('<input id="radio_update" type="radio" name="install_mode" value="upgrade" '.$sChecked.$sDisabled.'/><label for="radio_update">&nbsp;Upgrade an existing '.ITOP_APPLICATION.' instance</label>');
$sUpgradeDir = utils::HtmlEntities($sPreviousVersionDir);
$oPage->add(<<<HTML
<table id="upgrade_info"'.$sUpgradeInfoStyle.'>
<tr>
<td>Location on the disk:</td>
<td><input id="previous_version_dir_display" type="text" value="$sUpgradeDir" style="width: 98%;" disabled>
<input type="hidden" name="previous_version_dir" value="$sUpgradeDir"></td>
</tr>
HTML
);
SetupUtils::DisplayDBParameters($oPage, false, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix,
$sTlsEnabled, $sTlsCA, null);
@@ -310,12 +318,11 @@ class WizStepInstallOrUpgrade extends WizardStep
$oPage->add('<input type="hidden" id="authent_token" value="'.$sAuthentToken.'"/>');
//$oPage->add('</fieldset>');
$oPage->add_ready_script(
<<<EOF
<<<JS
$("#radio_update").bind('change', function() { if (this.checked ) { $('#upgrade_info').show(); WizardUpdateButtons(); } else { $('#upgrade_info').hide(); } });
$("#radio_install").bind('change', function() { if (this.checked ) { $('#upgrade_info').hide(); WizardUpdateButtons(); } else { $('#upgrade_info').show(); } });
$("#previous_version_dir").bind('change keyup', function() { WizardAsyncAction('check_path', { previous_version_dir: $('#previous_version_dir').val() }); });
$("#db_backup_path").bind('change keyup', function() { WizardAsyncAction('check_backup', { db_backup_path: $('#db_backup_path').val() }); });
EOF
JS
);
}
@@ -427,7 +434,6 @@ class WizStepDetectedInfo extends WizardStep
$this->oWizard->SetParameter('mode', 'upgrade');
$this->oWizard->SetParameter('upgrade_type', $sUpgradeType);
$this->oWizard->SaveParameter('copy_extensions_from', '');
$bDisplayLicense = $this->oWizard->GetParameter('display_license');
switch ($sUpgradeType)
@@ -634,29 +640,6 @@ HTML
}
// Check if there are "extensions" to preserve and if it's possible
if (is_dir($sPreviousVersionDir.'/extensions'))
{
$aExtensions = glob($sPreviousVersionDir.'/extensions/*', GLOB_ONLYDIR);
if (($aExtensions !== false) && (count($aExtensions)>0) && (realpath($sPreviousVersionDir.'/extensions') != realpath(APPROOT.'extensions')) )
{
$aWritableDirs = array('extensions');
$aErrors = SetupUtils::CheckWritableDirs($aWritableDirs);
if (count($aErrors) > 0)
{
$oPage->p("Cannot copy the extensions from '$sPreviousVersionDir/extensions' to '".APPROOT."extensions' due to the following access rights issue(s):");
foreach($aErrors as $sDir => $oCheckResult)
{
$oPage->add('<div class="message message-error"><span class="message-title">Error:</span>'.$oCheckResult->sLabel.'</div>');
}
}
else
{
$oPage->p("<b>Note:</b> The extensions present in '$sPreviousVersionDir/extensions' will be copied to '".APPROOT."extensions'.");
$oPage->add('<input type="hidden" name="copy_extensions_from" value="'.htmlentities($sPreviousVersionDir.'/extensions', ENT_QUOTES, 'UTF-8').'">');
}
}
}
$oPage->add_ready_script(
<<<EOF
$("#changes_summary .title").click(function() { $(this).parent().toggleClass('closed'); } );
@@ -1019,7 +1002,7 @@ class WizStepMiscParams extends WizardStep
$oPage->add('</fieldset>');
$oPage->add('<fieldset>');
$oPage->add('<legend>Path to Graphviz\' dot application</legend>');
$oPage->add('<table>');
$oPage->add('<table style="width: 100%;">');
$oPage->add('<tr><td>Path: </td><td><input id="graphviz_path" name="graphviz_path" type="text" size="35" maxlength="1024" value="'.htmlentities($sGraphvizPath, ENT_QUOTES, 'UTF-8').'"><span id="v_graphviz_path"/></td><tr>');
$oPage->add('<tr><td colspan="2"><a href="http://www.graphviz.org" target="_blank">Graphviz</a> is required to display the impact analysis graph (i.e. impacts / depends on).</td><tr>');
$oPage->add('<tr><td colspan="2"><span id="graphviz_status"></span></td><tr>');
@@ -1155,7 +1138,7 @@ class WizStepUpgradeMiscParams extends WizardStep
$oPage->add('</fieldset>');
$oPage->add('<fieldset>');
$oPage->add('<legend>Path to Graphviz\' dot application</legend>');
$oPage->add('<table>');
$oPage->add('<table style="width: 100%;">');
$oPage->add('<tr><td>Path: </td><td><input id="graphviz_path" name="graphviz_path" type="text" size="35" maxlength="1024" value="'.htmlentities($sGraphvizPath, ENT_QUOTES, 'UTF-8').'"><span id="v_graphviz_path"/></td><tr>');
$oPage->add('<tr><td colspan="2"><a href="http://www.graphviz.org" target="_blank">Graphviz</a> is required to display the impact analysis graph (i.e. impacts / depends on).</td><tr>');
$oPage->add('<tr><td colspan="2"><span id="graphviz_status"></span></td><tr>');
@@ -2366,22 +2349,6 @@ JS
$sSourceDir = APPROOT.'modules';
}
if (($sMode == 'upgrade'))
{
// Copy the previous extensions, if any
$sPreviousExtensionsDir = $this->oWizard->GetParameter('copy_extensions_from');
if (is_dir($sPreviousExtensionsDir))
{
// Copy the extensions one by one to merge them with the existing extensions in /extensions
$aExtensions = glob($sPreviousExtensionsDir.'/*', GLOB_ONLYDIR);
foreach($aExtensions as $sDirPath)
{
$sExtName = basename($sDirPath);
$aCopies[] = array('source' => $sDirPath, 'destination' => 'extensions/'.$sExtName); // Source is an absolute path, destination is relative to APPROOT
}
}
}
$aInstallParams = array (
'mode' => $sMode,
'preinstall' => array (