Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destroy database connection only if it has a connection already #13132

Merged
merged 1 commit into from Jul 8, 2018

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Jul 4, 2018

Otherwise it would create a connection just to destroy it. Noticed this when my tests were failing because of this.

Failed to setup fixture: TEST INITIALIZATION FAILED: SQLSTATE[HY000] [1049] Unknown database 'piwik_tests'
#0 libs/Zend/Db/Adapter/Pdo/Mysql.php(109): Zend_Db_Adapter_Pdo_Abstract->_connect()
#1 core/Db/Adapter/Pdo/Mysql.php(96): Zend_Db_Adapter_Pdo_Mysql->_connect()
#2 core/Db/Adapter/Pdo/Mysql.php(74): Piwik\Db\Adapter\Pdo\Mysql->_connect()
#3 core/Db/Adapter.php(51): Piwik\Db\Adapter\Pdo\Mysql->getConnection()
#4 core/Db.php(122): Piwik\Db\Adapter::factory('PDO\\MYSQL', Array)
#5 core/Db.php(54): Piwik\Db::createDatabaseObject()
#6 core/DbHelper.php(142): Piwik\Db::get()
#7 core/Db.php(144): Piwik\DbHelper::disconnectDatabase()
#8 tests/PHPUnit/Framework/Fixture.php(869): Piwik\Db::destroyDatabaseObject()
#9 tests/PHPUnit/Framework/Fixture.php(227): Piwik\Tests\Framework\Fixture::connectWithoutDatabase()
#10 tests/PHPUnit/Framework/TestCase/SystemTestCase.php(76): Piwik\Tests\Framework\Fixture->performSetUp()
#11 tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php(61): Piwik\Tests\Framework\TestCase\SystemTestCase::setUpBeforeClass()

Otherwise it would create a connection just to destroy it. Noticed this when my tests were failing because of this.

```
Failed to setup fixture: TEST INITIALIZATION FAILED: SQLSTATE[HY000] [1049] Unknown database 'piwik_tests'
#0 libs/Zend/Db/Adapter/Pdo/Mysql.php(109): Zend_Db_Adapter_Pdo_Abstract->_connect()
#1 core/Db/Adapter/Pdo/Mysql.php(96): Zend_Db_Adapter_Pdo_Mysql->_connect()
#2 core/Db/Adapter/Pdo/Mysql.php(74): Piwik\Db\Adapter\Pdo\Mysql->_connect()
#3 core/Db/Adapter.php(51): Piwik\Db\Adapter\Pdo\Mysql->getConnection()
#4 core/Db.php(122): Piwik\Db\Adapter::factory('PDO\\MYSQL', Array)
#5 core/Db.php(54): Piwik\Db::createDatabaseObject()
#6 core/DbHelper.php(142): Piwik\Db::get()
#7 core/Db.php(144): Piwik\DbHelper::disconnectDatabase()
#8 tests/PHPUnit/Framework/Fixture.php(869): Piwik\Db::destroyDatabaseObject()
#9 tests/PHPUnit/Framework/Fixture.php(227): Piwik\Tests\Framework\Fixture::connectWithoutDatabase()
#10 tests/PHPUnit/Framework/TestCase/SystemTestCase.php(76): Piwik\Tests\Framework\Fixture->performSetUp()
#11 tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php(61): Piwik\Tests\Framework\TestCase\SystemTestCase::setUpBeforeClass()
```
@tsteur tsteur added the Needs Review PRs that need a code review label Jul 4, 2018
@mattab mattab added this to the 3.6.0 milestone Jul 6, 2018
@diosmosis diosmosis merged commit 7ac9ff8 into 3.x-dev Jul 8, 2018
@diosmosis diosmosis deleted the destroydbconnonlyifexists branch July 8, 2018 19:12
InfinityVoid pushed a commit to InfinityVoid/matomo that referenced this pull request Oct 11, 2018
…mo-org#13132)

Otherwise it would create a connection just to destroy it. Noticed this when my tests were failing because of this.

```
Failed to setup fixture: TEST INITIALIZATION FAILED: SQLSTATE[HY000] [1049] Unknown database 'piwik_tests'
#0 libs/Zend/Db/Adapter/Pdo/Mysql.php(109): Zend_Db_Adapter_Pdo_Abstract->_connect()
#1 core/Db/Adapter/Pdo/Mysql.php(96): Zend_Db_Adapter_Pdo_Mysql->_connect()
matomo-org#2 core/Db/Adapter/Pdo/Mysql.php(74): Piwik\Db\Adapter\Pdo\Mysql->_connect()
matomo-org#3 core/Db/Adapter.php(51): Piwik\Db\Adapter\Pdo\Mysql->getConnection()
matomo-org#4 core/Db.php(122): Piwik\Db\Adapter::factory('PDO\\MYSQL', Array)
matomo-org#5 core/Db.php(54): Piwik\Db::createDatabaseObject()
matomo-org#6 core/DbHelper.php(142): Piwik\Db::get()
matomo-org#7 core/Db.php(144): Piwik\DbHelper::disconnectDatabase()
matomo-org#8 tests/PHPUnit/Framework/Fixture.php(869): Piwik\Db::destroyDatabaseObject()
matomo-org#9 tests/PHPUnit/Framework/Fixture.php(227): Piwik\Tests\Framework\Fixture::connectWithoutDatabase()
matomo-org#10 tests/PHPUnit/Framework/TestCase/SystemTestCase.php(76): Piwik\Tests\Framework\Fixture->performSetUp()
matomo-org#11 tests/PHPUnit/Framework/TestCase/IntegrationTestCase.php(61): Piwik\Tests\Framework\TestCase\SystemTestCase::setUpBeforeClass()
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants