Project

General

Profile

Actions

Bug #72285

closed

Dbal fails to connect to database with type native, when no portnumber is given

Added by Melanie Kalka almost 9 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Database API (Doctrine DBAL)
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 #1

Updated by Markus Klein almost 9 years ago

Can you push a fix to gerrit?

Actions #2

Updated by Markus Klein almost 9 years ago

  • Status changed from New to Accepted
  • Target version set to Candidate for patchlevel
Actions #3

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

Actions #4

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

Actions #5

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

Actions #6

Updated by Melanie Kalka almost 9 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #7

Updated by Benni Mack about 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF