From edcc94061616919f9f134d5e1e542d36e42830a6 Mon Sep 17 00:00:00 2001 From: redray Date: Mon, 15 Dec 2008 13:06:32 +0000 Subject: [PATCH] crop db user if longer than 16 chars (mysql limit) --- interface/web/sites/database_edit.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/interface/web/sites/database_edit.php b/interface/web/sites/database_edit.php index 4c4afa555b..05ef15bcd5 100644 --- a/interface/web/sites/database_edit.php +++ b/interface/web/sites/database_edit.php @@ -251,8 +251,9 @@ class page_action extends tform_actions { if ($app->tform->errorMessage == ''){ /* restrict the names if there is no error */ - $this->dataRecord['database_name'] = $dbname_prefix . $this->dataRecord['database_name']; - $this->dataRecord['database_user'] = $dbuser_prefix . $this->dataRecord['database_user']; + /* crop user and db names if they are too long -> mysql: user: 16 chars / db: 64 chars */ + $this->dataRecord['database_name'] = substr($dbname_prefix . $this->dataRecord['database_name'], 0, 64); + $this->dataRecord['database_user'] = substr($dbuser_prefix . $this->dataRecord['database_user'], 0, 16); } parent::onBeforeUpdate(); @@ -268,8 +269,9 @@ class page_action extends tform_actions { $dbuser_prefix = replacePrefix($global_config['dbuser_prefix'], $this->dataRecord); /* restrict the names */ - $this->dataRecord['database_name'] = $dbname_prefix . $this->dataRecord['database_name']; - $this->dataRecord['database_user'] = $dbuser_prefix . $this->dataRecord['database_user']; + /* crop user and db names if they are too long -> mysql: user: 16 chars / db: 64 chars */ + $this->dataRecord['database_name'] = substr($dbname_prefix . $this->dataRecord['database_name'], 0, 64); + $this->dataRecord['database_user'] = substr($dbuser_prefix . $this->dataRecord['database_user'], 0, 16); parent::onBeforeInsert(); } -- GitLab