Skip to content

Using a user-provided PDO connection breaks assertion #3487

Closed
@morozov

Description

@morozov
Q A
Regression yes
Version 2.10.0-dev

The following code is expected to work:

var_dump(
    DriverManager::getConnection([
        'pdo' => new PDO('sqlite::memory:'),
    ])->ping()
);

// bool(true)

On master, it currently produces:

Warning: assert(): assert($this->_conn instanceof DriverConnection) failed in lib/Doctrine/DBAL/Connection.php on line 1429

bool(true)

On develop:

Warning: assert(): assert($this->_conn instanceof DriverConnection) failed in /home/morozov/Projects/dbal/lib/Doctrine/DBAL/Connection.php on line 1374

TypeError: Return value of Doctrine\DBAL\Connection::query() must be an instance of Doctrine\DBAL\Driver\ResultStatement, instance of PDOStatement returned in lib/Doctrine/DBAL/Connection.php on line 995

The existing implementation relies on weak/duck typing since instead of injecting the PDO instance into PDOConnection, the latter gets replaced. Besides the poor design, this "feature" is completely untested.

We can loosen or remove the assertion from master but before fixing it in develop I'd like to understand the use cases this feature was implemented for.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions