fix keep-current-password when editing mysql-server

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-10-24 14:25:53 +02:00
parent a55cd86a4c
commit 1f69ab7e3f

View File

@@ -131,7 +131,7 @@ class MysqlServer extends ApiCommand implements ResourceEntity
require Froxlor::getInstallDir() . "/lib/userdata.inc.php";
// le format
if (isset($sql['root_user']) && isset($sql['root_password']) &&!is_array($sql_root)) {
if (isset($sql['root_user']) && isset($sql['root_password']) && !is_array($sql_root)) {
$sql_root = array(
0 => array(
'caption' => 'Default',
@@ -377,7 +377,7 @@ class MysqlServer extends ApiCommand implements ResourceEntity
$mysql_ca = $this->getParam('mysql_ca', true, $result['ssl']['caFile'] ?? '');
$mysql_verifycert = $this->getBoolParam('mysql_verifycert', true, $result['ssl']['verifyServerCertificate'] ?? 0);
$privileged_user = $this->getParam('privileged_user', true, $result['user']);
$privileged_password = $this->getParam('privileged_password', true, $result['password']);
$privileged_password = $this->getParam('privileged_password', true, '');
$description = $this->getParam('description', true, $result['caption']);
$allow_all_customers = $this->getParam('allow_all_customers', true, 0);
$test_connection = $this->getParam('test_connection', true, 1);
@@ -397,6 +397,11 @@ class MysqlServer extends ApiCommand implements ResourceEntity
$privileged_password = Validate::validate($privileged_password, 'password', '', '', [], true);
$description = Validate::validate(trim($description), 'description', Validate::REGEX_DESC_TEXT, '', [], true);
// keep old password?
if (empty($privileged_password)) {
$privileged_password = $result['password'];
}
if ($mysql_host != $result['host']) {
// check whether the server is in use by any customer
$result_ms = $this->databasesOnServer(true, $dbserver);