Bug #72285
closedDbal fails to connect to database with type native, when no portnumber is given
100%
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.
Updated by Markus Klein almost 9 years ago
- Status changed from New to Accepted
- Target version set to Candidate for patchlevel
Updated by Gerrit Code Review almost 9 years ago
- Status changed from Accepted to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/45338
Updated by Gerrit Code Review almost 9 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/45338
Updated by Gerrit Code Review almost 9 years ago
Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/45340
Updated by Melanie Kalka almost 9 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 48db3bf3a9471bd742e24d6031e0d2ba37834832.