Fix better error message if password is empty

This commit is contained in:
Laurent Destailleur 2021-07-12 10:35:25 +02:00
parent 4b2bbd0364
commit aece3844c6

View File

@ -531,6 +531,14 @@ if (!$error && $db->connected && $action == "set") {
if ($db->connected) { if ($db->connected) {
$resultbis = 1; $resultbis = 1;
if (empty($dolibarr_main_db_pass)) {
dolibarr_install_syslog("step1: failed to create user, password is empty", LOG_ERR);
print '<tr><td>';
print $langs->trans("UserCreation").' : ';
print $dolibarr_main_db_user;
print '</td>';
print '<td>'.$langs->trans("Error").": A password for database user is mandatory.</td></tr>";
} else {
// Create user // Create user
$result = $db->DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name); $result = $db->DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name);
@ -566,6 +574,7 @@ if (!$error && $db->connected && $action == "set") {
print '<td>'.$langs->trans("Error").': '.$db->errno().' '.$db->error().($db->error ? '. '.$db->error : '')."</td></tr>"; print '<td>'.$langs->trans("Error").': '.$db->errno().' '.$db->error().($db->error ? '. '.$db->error : '')."</td></tr>";
} }
} }
}
$db->close(); $db->close();
} else { } else {