Skip to content

Commit 4500741

Browse files
author
Marius Burkard
committed
- simplified MR !533
1 parent d70dc80 commit 4500741

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

server/plugins-available/mysql_clientdb_plugin.inc.php

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -683,31 +683,23 @@ function db_user_update($event_name, $data) {
683683
$result = $app->db->queryOneRecord("SELECT VERSION() as version");
684684
$dbversion = $result['version'];
685685

686-
// mariadb
687-
if(stripos($dbversion, 'mariadb') !== false) {
686+
// mariadb or mysql < 5.7
687+
if(stripos($dbversion, 'mariadb') !== false || version_compare($dbversion, '5.7', '<')) {
688688
$query = sprintf("SET PASSWORD FOR '%s'@'%s' = '%s'",
689689
$link->escape_string($data['new']['database_user']),
690690
$db_host,
691691
$link->escape_string($data['new']['database_password']));
692692
$link->query($query);
693693
}
694-
// mysql
694+
// mysql >= 5.7
695695
else {
696-
if (version_compare($dbversion, '5.7') >= 0) {
697-
$query = sprintf("ALTER USER IF EXISTS '%s'@'%s' IDENTIFIED WITH mysql_native_password AS '%s'",
698-
$link->escape_string($data['new']['database_user']),
699-
$db_host,
700-
$link->escape_string($data['new']['database_password']));
701-
$link->query($query);
702-
} else {
703-
$query = sprintf("SET PASSWORD FOR '%s'@'%s' = '%s'",
704-
$link->escape_string($data['new']['database_user']),
705-
$db_host,
706-
$link->escape_string($data['new']['database_password']));
707-
$link->query($query);
708-
}
709-
$app->log('Changing MySQL user password for: ' . $data['new']['database_user'] . '@' . $db_host, LOGLEVEL_DEBUG);
696+
$query = sprintf("ALTER USER IF EXISTS '%s'@'%s' IDENTIFIED WITH mysql_native_password AS '%s'",
697+
$link->escape_string($data['new']['database_user']),
698+
$db_host,
699+
$link->escape_string($data['new']['database_password']));
700+
$link->query($query);
710701
}
702+
$app->log('Changing MySQL user password for: ' . $data['new']['database_user'] . '@' . $db_host, LOGLEVEL_DEBUG);
711703
}
712704
}
713705

0 commit comments

Comments
 (0)