diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index cca641403b..8279daba5d 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -116,6 +116,11 @@ class container_builder */ private $env_parameters = []; + /** + * @var \phpbb\db\driver\driver_interface + */ + protected $dbal_connection = null; + /** * Constructor * @@ -568,20 +573,22 @@ class container_builder $config_data = $this->config_php_file->get_all(); if (!empty($config_data)) { - $dbal_driver_class = \phpbb\config_php_file::convert_30_dbms_to_31($this->config_php_file->get('dbms')); - /** @var \phpbb\db\driver\driver_interface $dbal_connection */ - $dbal_connection = new $dbal_driver_class(); - $dbal_connection->sql_connect( - $this->config_php_file->get('dbhost'), - $this->config_php_file->get('dbuser'), - $this->config_php_file->get('dbpasswd'), - $this->config_php_file->get('dbname'), - $this->config_php_file->get('dbport'), - false, - defined('PHPBB_DB_NEW_LINK') && PHPBB_DB_NEW_LINK - ); - //$this->dbal_connection_doctrine = connection_factory::get_connection($this->config_php_file); - $this->container->set('dbal.conn.driver', $dbal_connection); + if ($this->dbal_connection === null) + { + $dbal_driver_class = \phpbb\config_php_file::convert_30_dbms_to_31($this->config_php_file->get('dbms')); + /** @var \phpbb\db\driver\driver_interface $dbal_connection */ + $this->dbal_connection = new $dbal_driver_class(); + $this->dbal_connection->sql_connect( + $this->config_php_file->get('dbhost'), + $this->config_php_file->get('dbuser'), + $this->config_php_file->get('dbpasswd'), + $this->config_php_file->get('dbname'), + $this->config_php_file->get('dbport'), + false, + defined('PHPBB_DB_NEW_LINK') && PHPBB_DB_NEW_LINK + ); + } + $this->container->set('dbal.conn.driver', $this->dbal_connection); } } diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index f6344abdb2..70295b2165 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -360,7 +360,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case public function test_perform_schema_changes_drop_tables() { $db_tools = $this->getMockBuilder('\phpbb\db\tools\doctrine') - ->onlyMethods(array('sql_table_exists', '_schema_drop_table')) + ->onlyMethods(array('sql_table_exists', 'schema_drop_table')) ->setConstructorArgs(array($this->doctrine_db)) ->getMock(); @@ -369,7 +369,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case ->will($this->returnValue(true)); // drop tables - $db_tools->expects($this->exactly(2))->method('_schema_drop_table') + $db_tools->expects($this->exactly(2))->method('schema_drop_table') ->withConsecutive( [$this->isInstanceOf(Schema::class), 'dropped_table_1', true], [$this->isInstanceOf(Schema::class), 'dropped_table_2', true]