N°2249 - Supportability - Updater module

This commit is contained in:
Eric
2019-11-07 13:14:20 +01:00
parent 5e7ae930c5
commit da1684a8b9
3 changed files with 25 additions and 11 deletions

View File

@@ -89,15 +89,13 @@ class ApplicationInstaller
* some information about the progress and the success of the various
* sequential steps.
*
* @param bool $bSwitchToMaintenance
*
* @param bool $bVerbose
* @param string|null $sMessage
* @param string|null $sInstallComment
*
* @return boolean True if the installation was successful, false otherwise
*/
public function ExecuteAllSteps($bSwitchToMaintenance = true, $bVerbose = true, &$sMessage = null, $sInstallComment = null)
public function ExecuteAllSteps($bVerbose = true, &$sMessage = null, $sInstallComment = null)
{
$sStep = '';
$sStepLabel = '';
@@ -116,7 +114,7 @@ class ApplicationInstaller
echo "Starting the installation...\n";
}
}
$aRes = $this->ExecuteStep($sStep, $bSwitchToMaintenance, $sInstallComment);
$aRes = $this->ExecuteStep($sStep, $sInstallComment);
$sStep = $aRes['next-step'];
$sStepLabel = $aRes['next-step-label'];
$sMessage = $aRes['message'];
@@ -182,12 +180,11 @@ class ApplicationInstaller
* and the next step to perform
*
* @param string $sStep The identifier of the step to execute
* @param bool $bSwitchToMaintenance
* @param string|null $sInstallComment
*
* @return array (status => , message => , percentage-completed => , next-step => , next-step-label => )
*/
public function ExecuteStep($sStep = '', $bSwitchToMaintenance= true, $sInstallComment = null)
public function ExecuteStep($sStep = '', $sInstallComment = null)
{
try
{
@@ -604,7 +601,7 @@ class ApplicationInstaller
$oFactory->SaveToFile(APPROOT.'data/datamodel-'.$sEnvironment.'-with-delta.xml');
}
$oMFCompiler = new MFCompiler($oFactory);
$oMFCompiler = new MFCompiler($oFactory, $sEnvironment);
$oMFCompiler->Compile($sTargetPath, null, $bUseSymbolicLinks);
//$aCompilerLog = $oMFCompiler->GetLog();
//SetupPage::log_info(implode("\n", $aCompilerLog));
@@ -981,7 +978,8 @@ class ApplicationInstaller
// the default value on upgrade differs from the default value at first install
$oConfig->Set('tracking_level_linked_set_default', LINKSET_TRACKING_NONE, 'first_install');
}
$oConfig->Set('access_mode', ACCESS_FULL);
// Final config update: add the modules
$oConfig->UpdateFromParams($aParamValues, $sModulesDir, $bPreserveModuleSettings);
if ($bOldAddon)

View File

@@ -58,10 +58,13 @@ class MFCompiler
protected $sMainPHPCode; // Code that goes into core/main.php
protected $aSnippets;
protected $aRelations;
protected $sEnvironment;
public function __construct($oModelFactory)
public function __construct($oModelFactory, $sEnvironment)
{
$this->oFactory = $oModelFactory;
$this->sEnvironment = $sEnvironment;
$this->oFactory->ApplyChanges();
$this->aLog = array();
@@ -106,10 +109,15 @@ class MFCompiler
public function Compile($sTargetDir, $oP = null, $bUseSymbolicLinks = false, $bSkipTempDir = false)
{
$sFinalTargetDir = $sTargetDir;
$bIsAlreadyInMaintenanceMode = SetupUtils::IsInMaintenanceMode();
if ($bUseSymbolicLinks || $bSkipTempDir)
{
// Skip the creation of a temporary dictionary, not compatible with symbolic links
$sTempTargetDir = $sFinalTargetDir;
if (($this->sEnvironment == 'production') && !$bIsAlreadyInMaintenanceMode)
{
SetupUtils::EnterMaintenanceMode(new Config(utils::GetConfigFilePath($this->sEnvironment)));
}
}
else
{
@@ -137,9 +145,17 @@ class MFCompiler
if ($sTempTargetDir != $sFinalTargetDir)
{
// Move the results to the target directory
if (($this->sEnvironment == 'production') && !$bIsAlreadyInMaintenanceMode)
{
SetupUtils::EnterMaintenanceMode(new Config(utils::GetConfigFilePath($this->sEnvironment)));
}
SetupUtils::movedir($sTempTargetDir, $sFinalTargetDir);
}
if (($this->sEnvironment == 'production') && !$bIsAlreadyInMaintenanceMode)
{
SetupUtils::ExitMaintenanceMode();
}
// Reset the opcache since otherwise the PHP "model" files may still be cached !!
// In case of bad luck (this happens **sometimes** - see N. 550), we may analyze the database structure
// with the previous datamodel still loaded (in opcode cache) and thus fail to create the new fields

View File

@@ -525,7 +525,7 @@ class RunTimeEnvironment
$sTargetDir = APPROOT.'env-'.$this->sTargetEnv;
self::MakeDirSafe($sTargetDir);
$bSkipTempDir = ($this->sFinalEnv != $this->sTargetEnv); // No need for a temporary directory if sTargetEnv is already a temporary directory
$oMFCompiler = new MFCompiler($oFactory);
$oMFCompiler = new MFCompiler($oFactory, $this->sFinalEnv);
$oMFCompiler->Compile($sTargetDir, null, $bUseSymLinks, $bSkipTempDir);
$sCacheDir = APPROOT.'data/cache-'.$this->sTargetEnv;