? Pending

User tests: Successful: Unsuccessful:

avatar pe7er
pe7er
21 Apr 2019

Pull Request for Issue #24657 [installation] Hyphen not allowed anymore in MySQL database name?

Summary of Changes

This PR allows you to use a hyphen in the database name when installing Joomla.

Testing Instructions

When installing Joomla 4.0 try to use a database name with hyphen, like "joomla-cms"

Expected result

In Joomla 3.x it was possible to use a hyphen in the database name.
I would expect to be able to use a database name with hyphen in Joomla 4 as well.

Actual result

Using a MySQL database name with a hyphen (like "joomla-cms") results in a warning:
The database name is invalid. It must start with a letter, followed by alphanumeric characters.
and you have to change the name to something without a hyphen to continue.

avatar pe7er pe7er - open - 21 Apr 2019
avatar pe7er pe7er - change - 21 Apr 2019
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 21 Apr 2019
Category Installation
avatar franz-wohlkoenig franz-wohlkoenig - change - 21 Apr 2019
Title
#24657 - fix to allow hyphen in MySQL database name
fix to allow hyphen in MySQL database name
avatar franz-wohlkoenig franz-wohlkoenig - edited - 21 Apr 2019
avatar wilsonge
wilsonge - comment - 21 Apr 2019

Can you fix the conflicts here please @pe7er

avatar brianteeman
brianteeman - comment - 21 Apr 2019

@pe7er you are editing a very old version of the file afaict

avatar pe7er
pe7er - comment - 21 Apr 2019

@wilsonge Ok, I will
@brianteeman I was already wondering why + how to resolve the conflicts :-) Thanks!

avatar pe7er
pe7er - comment - 21 Apr 2019

I've updated my local 4.0-dev and resolved the conflict locally.
But when testing the installation again without my patch for MySQL,
the problem was not there anymore...
Closing this issue....

avatar pe7er pe7er - change - 21 Apr 2019
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2019-04-21 13:44:57
Closed_By pe7er
Labels Added: ?
avatar pe7er pe7er - close - 21 Apr 2019
avatar HLeithner
HLeithner - comment - 22 Apr 2019

I've updated my local 4.0-dev and resolved the conflict locally.
But when testing the installation again without my patch for MySQL,
the problem was not there anymore...
Closing this issue....

Are you sure this works, the regex should not allow "-" as database...

avatar infograf768
infograf768 - comment - 22 Apr 2019

@HLeithner
Just tested and hyphen works without this patch indeed.
Screen Shot 2019-04-22 at 09 03 25

EDIT: this is weird.

avatar infograf768
infograf768 - comment - 22 Apr 2019

In fact, in the present code initialise method the regular expression is:

		if (in_array($options->db_type, ['mysql', 'mysqli']) && preg_match('#[\\\\\/\.]#', $options->db_name))
		{
			Factory::getApplication()->enqueueMessage(Text::_('INSTL_DATABASE_NAME_MSG_MYSQL'), 'warning');

			return false;
		}

For postgresql it is

		// Validate database name.
		if (in_array($options->db_type, ['pgsql', 'postgresql'], true) && !preg_match('#^[a-zA-Z_][0-9a-zA-Z_$]*$#', $options->db_name))
		{
			Factory::getApplication()->enqueueMessage(Text::_('INSTL_DATABASE_NAME_MSG_POSTGRESQL'), 'warning');

			return false;
		}
avatar HLeithner
HLeithner - comment - 22 Apr 2019

thx @infograf768 for confirmation.

avatar infograf768
infograf768 - comment - 22 Apr 2019

It does not explain though why the hyphen is not accepted for postgresql but is for mysqli...

avatar HLeithner
HLeithner - comment - 22 Apr 2019

because its not allowed in postgressql

https://www.postgresql.org/docs/9.2/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

SQL identifiers and key words must begin with a letter (a-z, but also letters with diacritical marks and non-Latin letters) or an underscore (_). Subsequent characters in an identifier or key word can be letters, underscores, digits (0-9), or dollar signs ($). Note that dollar signs are not allowed in identifiers according to the letter of the SQL standard, so their use might render applications less portable. The SQL standard will not define a key word that contains digits or starts or ends with an underscore, so identifiers of this form are safe against possible conflict with future extensions of the standard.

Add a Comment

Login with GitHub to post a comment