? ? Pending

User tests: Successful: Unsuccessful:

avatar richard67
richard67
14 Mar 2020

Pull Request for Issue # .

Summary of Changes

With Pull Request (PR) #28135 I have added the check for the CMS' minimum database server version requirement to the installation, because the CMS requirement is at least for PostgreSQL more strict than the database driver's requirement, which was the only checked one before that PR.

But that PR has fixed that only for the case when the database already exists in case of MySQL (PDO) and PostgreSQL (PDO). When creating a new database during installation and using these drivers, still only the database driver's requirement is checked. For MySQLi that is not a problem because there the check in the setup model (which respects the CMS' requirement) works also when the database doesn't exist (yet).

This PR here corrects this so it works for all 3 drivers.

In addition it adds the same checks for connection encryption after successful connection to the database model as I have added them with my PR #27348 when I had added the connection encryption feature to the installation. The reason for this change is the same: Without this PR here these checks take only place when the database already exists, but not when a new database is created. This change is harder to test, because it is only relevant for the special case that the server doesn't support encryption, or negotiating an encrypted connection fails, and the server is configured to allow to fall back to an unencrypted connection. This part can only be tested by code review, I think.

Testing Instructions

Requirements

  1. You need a database server with a version which does fulfill the particular database driver's requirement on the minimum server version but doesn't fulfill the CMS' requirement on the minimum server version.

The minimum database server versions currently required by the database drivers are:

  • 5.6 for MySQLi and MySQL (PDO) drivers when using a MySQL database
  • 10.0 for MySQLi and MySQL (PDO) drivers when using a MariaDB database
  • 9.4.0 for PostgreSQL

The minimum database server versions currently required by the CMS are:

  • 5.6 for MySQL database
  • 10.0 for MariaDB database
  • 11.0 for PostgreSQL database

Because for MySQL and MariaDB the requirements of database driver and CMS are equal, you have to patch either the driver's or the CMS' requirement so that the above condition is fulfilled. For PostgreSQL you either use a server version 10 or have to patch some requirements, too.

The minimum version as required by the particular database driver for the particular database type can be patched at the following places:

For MySQL databases

MySQLi driver - file libraries/vendor/joomla/database/src/Mysqli/MysqliDriver.php, line 86
MySQL (PDO) driver - file libraries/vendor/joomla/database/src/Mysql/MysqlDriver.php, line 72

protected static $dbMinimum = '5.6';

For MariaDB databases

MySQLi driver - file libraries/vendor/joomla/database/src/Mysqli/MysqliDriver.php, line 94
MySQL (PDO) driver - file libraries/vendor/joomla/database/src/Mysql/MysqlDriver.php, line 80

protected static $dbMinMariadb = '10.0';

For PostgreSQL databases

PostgreSQL (PDO) driver - file libraries/vendor/joomla/database/src/Pgsql/PgsqlDriver.php, line 54

protected static $dbMinimum = '9.4.0';

The minimum version as required by the CMS for the particular database type can be patched here:

/**
* The minimum database server version for MariaDB databases as required by the CMS.
* This is not necessarily equal to what the database driver requires.
*
* @var string
* @since 4.0.0
*/
protected static $dbMinimumMariaDb = '10.1';
/**
* The minimum database server version for MySQL databases as required by the CMS.
* This is not necessarily equal to what the database driver requires.
*
* @var string
* @since 4.0.0
*/
protected static $dbMinimumMySql = '5.6';
/**
* The minimum database server version for PostgreSQL databases as required by the CMS.
* This is not necessarily equal to what the database driver requires.
*
* @var string
* @since 4.0.0
*/
protected static $dbMinimumPostgreSql = '11.0';

  1. You need a database user who has the privilege to create a database on that server with that kind of connection, e.g. on a standard installation of
  • MySql: user 'root' on host 'localhost'
  • MariaDB: no idea
  • PostgreSQL: user 'postgres'
  1. You need an up-to-date 4.0-dev branch so it contains the recently merged PR #28338 , or when using a nightly build, wait until tomorrow so that PR is included.

  2. This PR has to be tested with the PDO drivers, i.e. database type MySQL (PDO) or PosgreSQL (PDO). Of course if you have a MySQL or MariaDB database, you can test in addition if this PR doesn't break anything when using the MySQLi driver.

Instructions

Start a new Joomla 4 installation without the patch of this PR applied, using a database server and user combination which allows to create a new database, and a database name for which no database exists on that server, and make sure that for the server version the 1st point in section "Recuirements" above is fulfilled.

Result: See section "Actual result" below.

Do the same with the patch of this PR applied. When getting an error message about version requirement not being fulfilled, change database server or patch the requirement so that it will be fulfilled, and try again, using the "Install Jooma >" button again.

Result: See section "Expected result" below.

Finally check by code review that the checks for connection encryption added by this PR to here

// Check database connection encryption
if ($options->db_encryption !== 0 && empty($db->getConnectionEncryption()))
{
if ($db->isConnectionEncryptionSupported())
{
throw new \RuntimeException(Text::_('INSTL_DATABASE_ENCRYPTION_MSG_CONN_NOT_ENCRYPT'));
}
else
{
throw new \RuntimeException(Text::_('INSTL_DATABASE_ENCRYPTION_MSG_SRV_NOT_SUPPORTS'));
}
}

are the same as already present here
// Check database connection encryption
if ($options->db_encryption !== 0 && empty($db->getConnectionEncryption()))
{
if ($db->isConnectionEncryptionSupported())
{
Factory::getApplication()->enqueueMessage(Text::_('INSTL_DATABASE_ENCRYPTION_MSG_CONN_NOT_ENCRYPT'), 'error');
}
else
{
Factory::getApplication()->enqueueMessage(Text::_('INSTL_DATABASE_ENCRYPTION_MSG_SRV_NOT_SUPPORTS'), 'error');
}
$db->disconnect();
return false;
}

except that in the database model they raise exceptions instead of enqueueing messages and returning, but the exception texts are equal to the message texts used in the setup model.

Expected result

When creating a new database at installation, the CMS' requirement on the minimum database server version is checked, and if it is not fulfilled, the installation stops with an appropriate error message.

The user can correct database information in the installation form and then finish the installation by using the "Install Joomla >" button again.

Actual result

When creating a new database at installation, the CMS' requirement on the minimum database server version is not checked, i.e. Joomla is installed in that database even if the server doesn't fulfill the version requirement by the CMS.

Documentation Changes Required

None.

Additional information

This PR doesn't fix the fact that a database will also be created with MySQL (PDO) or PosgreSQL (PDO) when the server doesn't fulfill the minimum version requirement because that version check is done after database creation. This issue I plan to fix with another, future PR.

avatar richard67 richard67 - open - 14 Mar 2020
avatar richard67 richard67 - change - 14 Mar 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 14 Mar 2020
Category Installation
avatar richard67 richard67 - change - 14 Mar 2020
The description was changed
avatar richard67 richard67 - edited - 14 Mar 2020
avatar richard67 richard67 - change - 14 Mar 2020
The description was changed
avatar richard67 richard67 - edited - 14 Mar 2020
avatar richard67 richard67 - change - 14 Mar 2020
The description was changed
avatar richard67 richard67 - edited - 14 Mar 2020
avatar richard67 richard67 - change - 15 Mar 2020
The description was changed
avatar richard67 richard67 - edited - 15 Mar 2020
avatar richard67 richard67 - change - 15 Mar 2020
The description was changed
avatar richard67 richard67 - edited - 15 Mar 2020
avatar richard67 richard67 - change - 15 Mar 2020
The description was changed
avatar richard67 richard67 - edited - 15 Mar 2020
avatar richard67 richard67 - change - 15 Mar 2020
The description was changed
avatar richard67 richard67 - edited - 15 Mar 2020
avatar richard67 richard67 - change - 15 Mar 2020
The description was changed
avatar richard67 richard67 - edited - 15 Mar 2020
avatar richard67 richard67 - change - 15 Mar 2020
The description was changed
avatar richard67 richard67 - edited - 15 Mar 2020
avatar richard67 richard67 - change - 15 Mar 2020
The description was changed
avatar richard67 richard67 - edited - 15 Mar 2020
avatar richard67 richard67 - change - 15 Mar 2020
Title
[4.0] [Installation] [WiP] Fix minimum required version check when creating a new database
[4.0] [Installation] Fix minimum required version check when creating a new database
avatar richard67 richard67 - edited - 15 Mar 2020
avatar richard67 richard67 - change - 15 Mar 2020
Labels Added: ?
avatar richard67
richard67 - comment - 15 Mar 2020

Wait a bit with testing ... I have to adjust description so it is clear that the problem fixed by this PR doesn’t appear with MySQLi, only with MySQL (PDO) and PostgreSQL (PDO).

avatar richard67 richard67 - change - 15 Mar 2020
The description was changed
avatar richard67 richard67 - edited - 15 Mar 2020
avatar richard67
richard67 - comment - 15 Mar 2020

Done. Description adapted. Ready for test.

avatar jwaisner
jwaisner - comment - 17 Mar 2020

I have tested this item successfully on ef7f047

Test is successful with MariaDB. I get the proper error message and it reads the proper version that I am running.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28346.

avatar jwaisner jwaisner - test_item - 17 Mar 2020 - Tested successfully
avatar alikon
alikon - comment - 17 Apr 2020

I have tested this item successfully on ef7f047


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28346.

avatar alikon alikon - test_item - 17 Apr 2020 - Tested successfully
avatar alikon alikon - change - 17 Apr 2020
Status Pending Ready to Commit
avatar alikon
alikon - comment - 17 Apr 2020

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28346.

avatar richard67
richard67 - comment - 26 Apr 2020

Anything wrong with my PR? It is RTC, has no conflicts and is still valid.

avatar HLeithner HLeithner - close - 2 May 2020
avatar HLeithner HLeithner - merge - 2 May 2020
avatar HLeithner HLeithner - change - 2 May 2020
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2020-05-02 08:25:36
Closed_By HLeithner
Labels Added: ?
avatar HLeithner
HLeithner - comment - 2 May 2020

Thanks

avatar richard67
richard67 - comment - 2 May 2020

Thanks.

Add a Comment

Login with GitHub to post a comment