N°4286 Setup : restore backup download on WizStepDone

Setup token was put with N°2016 (6b5cc7c)
But later on we refactored the token handling in SetupUtils methods, and we had token removal in WizStepDone (43daa2ef) : so the backup download cannot be done :/
This commit is contained in:
Pierre Goiffon
2021-11-17 14:37:07 +01:00
parent be633001a5
commit 066b71686d
2 changed files with 9 additions and 3 deletions

View File

@@ -2507,11 +2507,13 @@ class WizStepDone extends WizardStep
$oPage->ok("The installation completed successfully.");
}
$bHasBackup = false;
if (($this->oWizard->GetParameter('mode', '') == 'upgrade') && $this->oWizard->GetParameter('db_backup', false) && $this->oWizard->GetParameter('authent', false))
{
$sBackupDestination = $this->oWizard->GetParameter('db_backup_path', '');
if (file_exists($sBackupDestination.'.tar.gz'))
{
$bHasBackup = true;
// To mitigate security risks: pass only the filename without the extension, the download will add the extension itself
$oPage->p('Your backup is ready');
$oPage->p('<a style="background:transparent;" href="'.utils::GetAbsoluteUrlAppRoot().'setup/ajax.dataloader.php?operation=async_action&step_class=WizStepDone&params[backup]='.urlencode($sBackupDestination).'&authent='.$this->oWizard->GetParameter('authent','').'" target="_blank"><img src="../images/tar.png" style="border:0;vertical-align:middle;">&nbsp;Download '.basename($sBackupDestination).'</a>');
@@ -2624,7 +2626,8 @@ class WizStepDone extends WizardStep
}
$idx = 0;
$aReportedModules = array();
while($idx < count($aAdditionalModules) && (strlen($sImgUrl.'&m='.urlencode(implode(' ', $aReportedModules))) < 2000)) // reasonable limit for the URL: 2000 chars
while ($idx < count($aAdditionalModules) && (strlen($sImgUrl.'&m='.urlencode(implode(' ',
$aReportedModules))) < 2000)) // reasonable limit for the URL: 2000 chars
{
$aReportedModules[] = $aAdditionalModules[$idx];
$idx++;
@@ -2634,7 +2637,10 @@ class WizStepDone extends WizardStep
$oPage->add('<img style="border:0" src="'.$sImgUrl.'"/>');
$sForm = addslashes($sForm);
$oPage->add_ready_script("$('#wiz_form').after('$sForm');");
SetupUtils::EraseSetupToken();
if (false === $bHasBackup) {
SetupUtils::EraseSetupToken();
}
}
public function CanMoveForward()