sebastianbergmann / dbunit

DbUnit port for PHP/PHPUnit.
https://phpunit.de/
Other
224 stars 190 forks source link

DefaultConnection does not close a connection. #203

Closed piotrbudny closed 6 years ago

piotrbudny commented 6 years ago

The DefaultConnection::close() does not close a connection.

From the PHP manual:

To close the connection, you need to destroy the object by ensuring that all remaining references to it are deleted—you do this by assigning NULL to the variable that holds the object.

As we can see below, a reference to the PDO object exists not only in the connection property but also in the metaData property:

    public function __construct(PDO $connection, $schema = '')
    {
        $this->connection = $connection;
        $this->metaData   = AbstractMetadata::createMetaData($connection, $schema);
        $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    }

therefore the close() method should be updated to:

    public function close()
    {
        unset($this->connection);
        unset($this->metaData);
    }
stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had activity within the last 60 days. It will be closed after 7 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 6 years ago

This issue has been automatically closed because it has not had activity since it was marked as stale. Thank you for your contributions.