Actions
Bug #72285
closedDbal fails to connect to database with type native, when no portnumber is given
Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Database API (Doctrine DBAL)
Target version:
Start date:
2015-12-17
Due date:
% Done:
100%
Estimated time:
TYPO3 Version:
6.2
PHP Version:
5.5
Tags:
Complexity:
no-brainer
Is Regression:
No
Sprint Focus:
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.
Actions