From c4245e2c05ede1ac4a0d9072e6d0d822542909c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 27 Jan 2023 11:52:58 +0100 Subject: [PATCH] Prepare use of upgrade.unlock --- htdocs/install/step5.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index 31b086636f2..c516cc70aef 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -368,13 +368,16 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) { if ($action == "set") { if ($success) { if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) { - // Install is finished + // Install is finished (database is on same version than files) print '
'.$langs->trans("SystemIsInstalled")."
"; + // Create install.lock file + // No need for the moment to create it automatically, creation by web assistant means permissions are given + // to the web user, it is better to show a warning to say to create it manually with correct user/permission (not erasable by a web process) $createlock = 0; - if (!empty($force_install_lockinstall) || !empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE)) { - // Install is finished, we create the lock file + // Install is finished, we create the "install.lock" file, so install won't be possible anymore. + // TODO Upgrade will be still be possible if a file "upgrade.unlock" is present $lockfile = DOL_DATA_ROOT.'/install.lock'; $fp = @fopen($lockfile, "w"); if ($fp) { @@ -413,13 +416,14 @@ if ($action == "set") { } elseif (empty($action) || preg_match('/upgrade/i', $action)) { // If upgrade if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) { - // Upgrade is finished + // Upgrade is finished (database is on same version than files) print 'Configuration '.$langs->trans("SystemIsUpgraded")."
"; + // Create install.lock file if it does not exists. + // Note: it should always exists. A better solution to allow upgrade will be to add an upgrade.unlock file $createlock = 0; - if (!empty($force_install_lockinstall) || !empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE)) { - // Upgrade is finished, we create the lock file + // Upgrade is finished, we modify the lock file $lockfile = DOL_DATA_ROOT.'/install.lock'; $fp = @fopen($lockfile, "w"); if ($fp) { @@ -436,6 +440,10 @@ if ($action == "set") { print '
'.$langs->trans("WarningRemoveInstallDir")."
"; } + // Delete the upgrade.unlock file it it exists + $unlockupgradefile = DOL_DATA_ROOT.'/upgrade.unlock'; + dol_delete_file($unlockupgradefile, 0, 0, 0, null, false, 0); + print "
"; $morehtml = '
';