Browse Source

FIX install wizard error management

Laurent Destailleur 2 years ago
parent
commit
ff16d74bd2
1 changed files with 42 additions and 40 deletions
  1. 42 40
      htdocs/install/step5.php

+ 42 - 40
htdocs/install/step5.php

@@ -220,9 +220,9 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) {
 				print $langs->trans("AdminLoginCreatedSuccessfuly", $login)."<br>";
 				$success = 1;
 			} else {
-				if ($newuser->error == 'ErrorLoginAlreadyExists') {
+				if ($result == -6) {	//login or email already exists
 					dolibarr_install_syslog('step5: AdminLoginAlreadyExists', LOG_WARNING);
-					print '<br><div class="warning">'.$langs->trans("AdminLoginAlreadyExists", $login)."</div><br>";
+					print '<br><div class="warning">'.$newuser->error."</div><br>";
 					$success = 1;
 				} else {
 					dolibarr_install_syslog('step5: FailedToCreateAdminLogin '.$newuser->error, LOG_ERR);
@@ -357,48 +357,50 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i', $action)) {
 // Create lock file
 
 // If first install
-if ($action == "set" && $success) {
-	if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) {
-		// Install is finished
-		print $langs->trans("SystemIsInstalled")."<br>";
-
-		$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
-			$lockfile = DOL_DATA_ROOT.'/install.lock';
-			$fp = @fopen($lockfile, "w");
-			if ($fp) {
-				if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) {
-					$force_install_lockinstall = 444; // For backward compatibility
+if ($action == "set") {
+	if ($success) {
+		if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) {
+			// Install is finished
+			print $langs->trans("SystemIsInstalled")."<br>";
+
+			$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
+				$lockfile = DOL_DATA_ROOT.'/install.lock';
+				$fp = @fopen($lockfile, "w");
+				if ($fp) {
+					if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) {
+						$force_install_lockinstall = 444; // For backward compatibility
+					}
+					fwrite($fp, "This is a lock file to prevent use of install pages (set with permission ".$force_install_lockinstall.")");
+					fclose($fp);
+					@chmod($lockfile, octdec($force_install_lockinstall));
+					$createlock = 1;
 				}
-				fwrite($fp, "This is a lock file to prevent use of install pages (set with permission ".$force_install_lockinstall.")");
-				fclose($fp);
-				@chmod($lockfile, octdec($force_install_lockinstall));
-				$createlock = 1;
 			}
-		}
-		if (empty($createlock)) {
-			print '<div class="warning">'.$langs->trans("WarningRemoveInstallDir")."</div>";
-		}
-
-		print "<br>";
+			if (empty($createlock)) {
+				print '<div class="warning">'.$langs->trans("WarningRemoveInstallDir")."</div>";
+			}
 
-		print $langs->trans("YouNeedToPersonalizeSetup")."<br><br><br>";
+			print "<br>";
 
-		print '<div class="center"><a href="../admin/index.php?mainmenu=home&leftmenu=setup'.(isset($login) ? '&username='.urlencode($login) : '').'">';
-		print '<span class="fas fa-external-link-alt"></span> '.$langs->trans("GoToSetupArea");
-		print '</a></div>';
-	} else {
-		// If here MAIN_VERSION_LAST_UPGRADE is not empty
-		print $langs->trans("VersionLastUpgrade").': <b><span class="ok">'.$conf->global->MAIN_VERSION_LAST_UPGRADE.'</span></b><br>';
-		print $langs->trans("VersionProgram").': <b><span class="ok">'.DOL_VERSION.'</span></b><br>';
-		print $langs->trans("MigrationNotFinished").'<br>';
-		print "<br>";
+			print $langs->trans("YouNeedToPersonalizeSetup")."<br><br><br>";
 
-		print '<div class="center"><a href="'.$dolibarr_main_url_root.'/install/index.php">';
-		print '<span class="fas fa-link-alt"></span> '.$langs->trans("GoToUpgradePage");
-		print '</a></div>';
+			print '<div class="center"><a href="../admin/index.php?mainmenu=home&leftmenu=setup'.(isset($login) ? '&username='.urlencode($login) : '').'">';
+			print '<span class="fas fa-external-link-alt"></span> '.$langs->trans("GoToSetupArea");
+			print '</a></div>';
+		} else {
+			// If here MAIN_VERSION_LAST_UPGRADE is not empty
+			print $langs->trans("VersionLastUpgrade").': <b><span class="ok">'.$conf->global->MAIN_VERSION_LAST_UPGRADE.'</span></b><br>';
+			print $langs->trans("VersionProgram").': <b><span class="ok">'.DOL_VERSION.'</span></b><br>';
+			print $langs->trans("MigrationNotFinished").'<br>';
+			print "<br>";
+
+			print '<div class="center"><a href="'.$dolibarr_main_url_root.'/install/index.php">';
+			print '<span class="fas fa-link-alt"></span> '.$langs->trans("GoToUpgradePage");
+			print '</a></div>';
+		}
 	}
 } elseif (empty($action) || preg_match('/upgrade/i', $action)) {
 	// If upgrade
@@ -443,7 +445,7 @@ if ($action == "set" && $success) {
 		$morehtml .= '</a></div>';
 	}
 } else {
-	dol_print_error('', 'step5.php: unknown choice of action');
+	dol_print_error('', 'step5.php: unknown choice of action='.$action.' in create lock file seaction');
 }
 
 // Clear cache files