Ver código fonte

Prepare use of upgrade.unlock

Laurent Destailleur 2 anos atrás
pai
commit
c4245e2c05
1 arquivos alterados com 14 adições e 6 exclusões
  1. 14 6
      htdocs/install/step5.php

+ 14 - 6
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 '<br>'.$langs->trans("SystemIsInstalled")."<br>";
 
+			// 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 '<img class="valignmiddle inline-block paddingright" src="../theme/common/octicons/build/svg/checklist.svg" width="20" alt="Configuration"> <span class="valignmiddle">'.$langs->trans("SystemIsUpgraded")."</span><br>";
 
+		// 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 '<br><div class="warning">'.$langs->trans("WarningRemoveInstallDir")."</div>";
 		}
 
+		// 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 "<br>";
 
 		$morehtml = '<br><div class="center"><a href="../index.php?mainmenu=home'.(isset($login) ? '&username='.urlencode($login) : '').'">';