#72285Dbal fails to connect to database with type native, when no portnumber is given
Description
When configuring the Database Abstraction Layer as documented in the manual:
'alternativeMySQLdb' => array(
'type' => 'native',
'config' => array(
'username' => 'your_username',
'password' => 'your_password',
'host' => 'localhost',
'database' => 'alternative_database_name',
)
),
the database connection will fail, because of the following lines in typo3/sysext/dbal/Classes/Database/DatabaseConnection.php
$link = mysqli_init();
$connected = $link->real_connect(
$host,
$cfgArray['config']['username'],
$cfgArray['config']['password'],
$cfgArray['config']['database'],
isset($cfgArray['config']['port']) ? $cfgArray['config']['port'] : ''
);
if ($connected) {
When no portnumber is given, dbal replaces the parameter with an empty string instead of NULL.
Using an empty string produces a php warning:
Warning: mysqli::real_connect() expects parameter 5 to be long, string given
So the line should be changed to:
isset($cfgArray['config']['port']) ? $cfgArray['config']['port'] : NULL
The Bug applies at least to TYPO3 6.2 and 7.6.