From bc9140affd371391a467850ee670584162cf1e57 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sat, 26 May 2018 13:31:07 +0200 Subject: [PATCH] Make `htconfig.php` fit for MariaDB --- htconfig.php | 8 ++++++-- view/templates/htconfig.tpl | 15 ++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/htconfig.php b/htconfig.php index 2cbbf6335d..0e838bd90d 100644 --- a/htconfig.php +++ b/htconfig.php @@ -24,11 +24,15 @@ $db_data = 'mysqldatabasename'; // Use environment variables for mysql if they are set beforehand if (!empty(getenv('MYSQL_HOST')) && !empty(getenv('MYSQL_PORT')) - && !empty(getenv('MYSQL_USERNAME')) + && (!empty(getenv('MYSQL_USERNAME')) || !empty(getenv('MYSQL_USER'))) && !empty(getenv('MYSQL_PASSWORD')) && !empty(getenv('MYSQL_DATABASE'))) { $db_host = getenv('MYSQL_HOST') . ':' . getenv('MYSQL_PORT'); - $db_user = getenv('MYSQL_USERNAME'); + if (!empty(getenv('MYSQL_USERNAME'))) { + $db_user = getenv('MYSQL_USERNAME'); + } elseif (!empty(getenv('MYSQL_USER'))) { + $db_user = getenv('MYSQL_USER'); + } $db_pass = getenv('MYSQL_PASSWORD'); $db_data = getenv('MYSQL_DATABASE'); } diff --git a/view/templates/htconfig.tpl b/view/templates/htconfig.tpl index 1325a61771..dc2d4bcdab 100644 --- a/view/templates/htconfig.tpl +++ b/view/templates/htconfig.tpl @@ -19,16 +19,21 @@ $db_data = '{{$dbdata}}'; // Use environment variables for mysql if they are set beforehand if (!empty(getenv('MYSQL_HOST')) - && !empty(getenv('MYSQL_PORT')) - && !empty(getenv('MYSQL_USERNAME')) - && !empty(getenv('MYSQL_PASSWORD')) - && !empty(getenv('MYSQL_DATABASE'))) { + && !empty(getenv('MYSQL_PORT')) + && (!empty(getenv('MYSQL_USERNAME')) || !empty(getenv('MYSQL_USER'))) + && !empty(getenv('MYSQL_PASSWORD')) + && !empty(getenv('MYSQL_DATABASE'))) { $db_host = getenv('MYSQL_HOST') . ':' . getenv('MYSQL_PORT'); - $db_user = getenv('MYSQL_USERNAME'); + if (!empty(getenv('MYSQL_USERNAME'))) { + $db_user = getenv('MYSQL_USERNAME'); + } elseif (!empty(getenv('MYSQL_USER'))) { + $db_user = getenv('MYSQL_USER'); + } $db_pass = getenv('MYSQL_PASSWORD'); $db_data = getenv('MYSQL_DATABASE'); } + // Set the database connection charset to full Unicode (utf8mb4). // Changing this value will likely corrupt the special characters. // You have been warned. -- 2.39.5