laminas / laminas-db

Database abstraction layer, SQL abstraction, result set abstraction, and RowDataGateway and TableDataGateway implementations
https://docs.laminas.dev/laminas-db/
BSD 3-Clause "New" or "Revised" License
122 stars 68 forks source link

Fix issue with connection not released in specific scenario #292

Closed ionutf6s closed 9 months ago

ionutf6s commented 1 year ago

Use local variable instead of instance variable for storing select statement when in prepare mode

Q A
Documentation no
Bugfix yes
BC Break no
New Feature no
RFC no
QA no

Description

Found the issue while running integration tests using the database adapter. If in the same method you fetch something from database using \Laminas\Db\Adapter\Adapter::query in prepare mode and after use the table gateway to fetch something from the database, a reference to the PDO connection remains and is not released when trying to disconnect from the database.

Added a test case with the scenario with many tests in the data provider. On the tearDown I have disconnected from the database.