Merge branch '3.2.x'

This commit is contained in:
Marc Alexander 2017-01-04 17:30:05 +01:00
commit 5c2b9e0e37
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
10 changed files with 62 additions and 10 deletions

View file

@ -5,9 +5,7 @@ services:
- '@service_container' - '@service_container'
dbal.conn.driver: dbal.conn.driver:
class: '%dbal.driver.class%' synthetic: true
calls:
- [sql_connect, ['%dbal.dbhost%', '%dbal.dbuser%', '%dbal.dbpasswd%', '%dbal.dbname%', '%dbal.dbport%', false, '%dbal.new_link%']]
# ----- DB Tools ----- # ----- DB Tools -----
dbal.tools.factory: dbal.tools.factory:

View file

@ -50,6 +50,11 @@ class container_builder
*/ */
protected $container; protected $container;
/**
* @var \phpbb\db\driver\driver_interface
*/
protected $dbal_connection = null;
/** /**
* Indicates whether extensions should be used (default to true). * Indicates whether extensions should be used (default to true).
* *
@ -197,6 +202,8 @@ class container_builder
$this->container->set('config.php', $this->config_php_file); $this->container->set('config.php', $this->config_php_file);
} }
$this->inject_dbal_driver();
return $this->container; return $this->container;
} }
catch (\Exception $e) catch (\Exception $e)
@ -511,7 +518,38 @@ class container_builder
{ {
$this->container->setParameter($key, $value); $this->container->setParameter($key, $value);
} }
}
/**
* Inject the dbal connection driver into container
*/
protected function inject_dbal_driver()
{
if (empty($this->config_php_file))
{
return;
}
$config_data = $this->config_php_file->get_all();
if (!empty($config_data))
{
if ($this->dbal_connection === null)
{
$dbal_driver_class = $this->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);
}
} }
/** /**

View file

@ -43,12 +43,6 @@ class config extends Extension
'core.adm_relative_path' => $this->config_php->get('phpbb_adm_relative_path') ? $this->config_php->get('phpbb_adm_relative_path') : 'adm/', 'core.adm_relative_path' => $this->config_php->get('phpbb_adm_relative_path') ? $this->config_php->get('phpbb_adm_relative_path') : 'adm/',
'core.table_prefix' => $this->config_php->get('table_prefix'), 'core.table_prefix' => $this->config_php->get('table_prefix'),
'cache.driver.class' => $this->convert_30_acm_type($this->config_php->get('acm_type')), 'cache.driver.class' => $this->convert_30_acm_type($this->config_php->get('acm_type')),
'dbal.driver.class' => $this->config_php->convert_30_dbms_to_31($this->config_php->get('dbms')),
'dbal.dbhost' => $this->config_php->get('dbhost'),
'dbal.dbuser' => $this->config_php->get('dbuser'),
'dbal.dbpasswd' => $this->config_php->get('dbpasswd'),
'dbal.dbname' => $this->config_php->get('dbname'),
'dbal.dbport' => $this->config_php->get('dbport'),
'dbal.new_link' => defined('PHPBB_DB_NEW_LINK') && PHPBB_DB_NEW_LINK, 'dbal.new_link' => defined('PHPBB_DB_NEW_LINK') && PHPBB_DB_NEW_LINK,
); );
$parameter_bag = $container->getParameterBag(); $parameter_bag = $container->getParameterBag();

View file

@ -46,6 +46,7 @@ namespace
{ {
$container = $this->builder->get_container(); $container = $this->builder->get_container();
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container);
$this->assertFalse($container->hasParameter('container_exception'));
// Checks the core services // Checks the core services
$this->assertTrue($container->hasParameter('core')); $this->assertTrue($container->hasParameter('core'));
@ -54,7 +55,7 @@ namespace
$this->assertTrue($container->isFrozen()); $this->assertTrue($container->isFrozen());
// Checks inject_config // Checks inject_config
$this->assertTrue($container->hasParameter('dbal.dbhost')); $this->assertTrue($container->hasParameter('core.table_prefix'));
// Checks use_extensions // Checks use_extensions
$this->assertTrue($container->hasParameter('enabled')); $this->assertTrue($container->hasParameter('enabled'));

View file

@ -10,6 +10,9 @@ services:
arguments: arguments:
- '@service_container' - '@service_container'
dbal.conn.driver:
synthetic: true
dispatcher: dispatcher:
class: phpbb\db\driver\container_mock class: phpbb\db\driver\container_mock

View file

@ -10,6 +10,9 @@ services:
arguments: arguments:
- '@service_container' - '@service_container'
dbal.conn.driver:
synthetic: true
dispatcher: dispatcher:
class: phpbb\db\driver\container_mock class: phpbb\db\driver\container_mock

View file

@ -10,6 +10,9 @@ services:
arguments: arguments:
- '@service_container' - '@service_container'
dbal.conn.driver:
synthetic: true
dispatcher: dispatcher:
class: phpbb\db\driver\container_mock class: phpbb\db\driver\container_mock

View file

@ -10,6 +10,9 @@ services:
arguments: arguments:
- '@service_container' - '@service_container'
dbal.conn.driver:
synthetic: true
dispatcher: dispatcher:
class: phpbb\db\driver\container_mock class: phpbb\db\driver\container_mock

View file

@ -27,4 +27,12 @@ class phpbb_mock_phpbb_di_container_builder extends \phpbb\di\container_builder
{ {
return $this->phpbb_root_path . '../../tmp/autoload.' . $this->php_ext; return $this->phpbb_root_path . '../../tmp/autoload.' . $this->php_ext;
} }
/**
* {@inheritdoc}
*/
protected function inject_dbal_driver()
{
return;
}
} }

View file

@ -304,6 +304,7 @@ class phpbb_functional_test_case extends phpbb_test_case
], ],
'cache.driver.class' => 'phpbb\cache\driver\file' 'cache.driver.class' => 'phpbb\cache\driver\file'
]) ])
->with_config(new \phpbb\config_php_file($phpbb_root_path, $phpEx))
->without_compiled_container() ->without_compiled_container()
->get_container(); ->get_container();