From 47c71f6035b5c106995f76c760733ac28dfc4ce3 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Thu, 24 Nov 2022 10:03:23 +0100 Subject: [PATCH] adjust mysql-usernamelength values for mariadb according to docs Signed-off-by: Michael Kaufmann --- lib/Froxlor/Database/Database.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/Froxlor/Database/Database.php b/lib/Froxlor/Database/Database.php index 5235cf1158..5580144f8c 100644 --- a/lib/Froxlor/Database/Database.php +++ b/lib/Froxlor/Database/Database.php @@ -190,10 +190,16 @@ public static function getSqlData() */ public static function getSqlUsernameLength() { - // MySQL user names can be up to 32 characters long (16 characters before MySQL 5.7.8). - $mysql_max = 32; - if (version_compare(Database::getAttribute(\PDO::ATTR_SERVER_VERSION), '5.7.8', '<')) { - $mysql_max = 16; + // MariaDB supports up to 80 characters but only 64 for databases and as we use the loginname also for + // database names, we set the limit to 64 here + if (strpos(strtolower(Database::getAttribute(\PDO::ATTR_SERVER_VERSION)), "mariadb") !== false) { + $mysql_max = 64; + } else { + // MySQL user names can be up to 32 characters long (16 characters before MySQL 5.7.8). + $mysql_max = 32; + if (version_compare(Database::getAttribute(\PDO::ATTR_SERVER_VERSION), '5.7.8', '<')) { + $mysql_max = 16; + } } return $mysql_max; }