From 40937e21c58399a847d04f23423622b0e1894446 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 29 Jun 2014 00:29:08 +0200 Subject: [ticket/12775] Renamed to \phpbb\di\container_builder PHPBB3-12775 --- phpBB/phpbb/di/container_builder.php | 396 +++++++++++++++++++++++++++++++++++ 1 file changed, 396 insertions(+) create mode 100644 phpBB/phpbb/di/container_builder.php (limited to 'phpBB/phpbb/di/container_builder.php') diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php new file mode 100644 index 0000000000..426c411e07 --- /dev/null +++ b/phpBB/phpbb/di/container_builder.php @@ -0,0 +1,396 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\di; + +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Dumper\PhpDumper; + +class container_factory +{ + /** @var string phpBB Root Path */ + protected $phpbb_root_path; + + /** @var string php file extension */ + protected $php_ext; + + /** + * The container under construction + * + * @var ContainerBuilder + */ + protected $container; + + /** + * @var \phpbb\db\driver\driver_interface + */ + protected $dbal_connection = null; + + /** + * @var array the installed extensions + */ + protected $installed_exts = null; + + /** + * Indicates if the php config file should be injecting into the container (default to true). + * + * @var bool + */ + protected $inject_config = true; + + /** + * Indicates if the extensions should be used (default to true). + * + * @var bool + */ + protected $use_extensions = true; + + /** + * Defines a custom path to find the configuration of the container. + * + * @var string + */ + protected $config_path = null; + + /** + * Indicates if the phpBB compile pass have to be used (default to true). + * + * @var bool + */ + protected $use_custom_pass = true; + + /** + * Indicates if the kernel compile pass have to be used (default to true). + * + * @var bool + */ + protected $use_kernel_pass = true; + + /** + * Indicates if a dump container should be used (default to true). + * + * If DEBUG_CONTAINER is set this option is ignored and a new container is build. + * + * @var bool + */ + protected $dump_container = true; + + /** + * Indicates if the container should be compiled automatically (default to true). + * + * @var bool + */ + protected $compile_container = true; + + /** + * Custom parameters to inject into the container. + * + * Default to true: + * array( + * 'core.root_path', $this->phpbb_root_path, + * 'core.php_ext', $this->php_ext, + * ); + * + * @var array + */ + protected $custom_parameters = null; + + /** + * Constructor + * + * @param \phpbb\config_php $config_php_handler + * @param string $phpbb_root_path Path to the phpbb includes directory. + * @param string $php_ext php file extension + */ + function __construct(\phpbb\config_php $config_php_handler, $phpbb_root_path, $php_ext) + { + $this->config_php_handler = $config_php_handler; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + } + + /** + * Build and return a new Container respecting the current configuration + * + * @return \phpbb_cache_container|ContainerBuilder + */ + public function get_container() + { + $container_filename = $this->get_container_filename(); + if (!defined('DEBUG_CONTAINER') && $this->dump_container && file_exists($container_filename)) + { + require($container_filename); + $this->container = new \phpbb_cache_container(); + } + else + { + if ($this->config_path === null) + { + $this->config_path = $this->phpbb_root_path . 'config'; + } + $container_extensions = array(new \phpbb\di\extension\core($this->config_path)); + + if ($this->use_extensions) + { + $installed_exts = $this->get_installed_extensions(); + $container_extensions[] = new \phpbb\di\extension\ext($installed_exts); + } + + if ($this->inject_config) + { + $container_extensions[] = new \phpbb\di\extension\config($this->config_php_handler); + } + + $this->container = $this->create_container($container_extensions); + + if ($this->use_custom_pass) + { + $this->container->addCompilerPass(new \phpbb\di\pass\collection_pass()); + + if ($this->use_kernel_pass) + { + $this->container->addCompilerPass(new \phpbb\di\pass\kernel_pass()); + } + } + + $this->inject_custom_parameters(); + + if ($this->compile_container) + { + $this->container->compile(); + } + + if ($this->dump_container && !defined('DEBUG')) + { + $this->dump_container($container_filename); + } + } + + $this->container->set('config.php', $this->config_php_handler); + + // Frozen container, we can't modify either the services or the parameters + //$this->inject_dbal(); + + return $this->container; + } + + /** + * Set if the extensions should be used. + * + * @param bool $use_extensions + */ + public function set_use_extensions($use_extensions) + { + $this->use_extensions = $use_extensions; + } + + /** + * Set if the phpBB compile pass have to be used. + * + * @param bool $use_custom_pass + */ + public function set_use_custom_pass($use_custom_pass) + { + $this->use_custom_pass = $use_custom_pass; + } + + /** + * Set if the kernel compile pass have to be used. + * + * @param bool $use_kernel_pass + */ + public function set_use_kernel_pass($use_kernel_pass) + { + $this->use_kernel_pass = $use_kernel_pass; + } + + /** + * Set if the php config file should be injecting into the container. + * + * @param bool $inject_config + */ + public function set_inject_config($inject_config) + { + $this->inject_config = $inject_config; + } + + /** + * Set if a dump container should be used. + * + * If DEBUG_CONTAINER is set this option is ignored and a new container is build. + * + * @var bool $dump_container + */ + public function set_dump_container($dump_container) + { + $this->dump_container = $dump_container; + } + + /** + * Set if the container should be compiled automatically (default to true). + * + * @var bool $dump_container + */ + public function set_compile_container($compile_container) + { + $this->compile_container = $compile_container; + } + + /** + * Set a custom path to find the configuration of the container + * + * @param string $config_path + */ + public function set_config_path($config_path) + { + $this->config_path = $config_path; + } + + /** + * Set custom parameters to inject into the container. + * + * @param array $custom_parameters + */ + public function set_custom_parameters($custom_parameters) + { + $this->custom_parameters = $custom_parameters; + } + + /** + * Dump the container to the disk. + * + * @param string $container_filename The name of the file. + */ + protected function dump_container($container_filename) + { + // Lastly, we create our cached container class + $dumper = new PhpDumper($this->container); + $cached_container_dump = $dumper->dump(array( + 'class' => 'phpbb_cache_container', + 'base_class' => 'Symfony\\Component\\DependencyInjection\\ContainerBuilder', + )); + + file_put_contents($container_filename, $cached_container_dump); + } + + /** + * Inject the connection into the container if one was opened. + */ + protected function inject_dbal() + { + if ($this->dbal_connection !== null) + { + $this->container->set('dbal.conn', $this->dbal_connection); + } + } + + /** + * Get DB connection. + * + * @return \phpbb\db\driver\driver_interface + */ + protected function get_dbal_connection() + { + if ($this->dbal_connection === null) + { + $dbal_driver_class = phpbb_convert_30_dbms_to_31($this->config_php_handler->get('dbms')); + $this->dbal_connection = new $dbal_driver_class(); + $this->dbal_connection->sql_connect( + $this->config_php_handler->get('dbhost'), + $this->config_php_handler->get('dbuser'), + $this->config_php_handler->get('dbpasswd'), + $this->config_php_handler->get('dbname'), + $this->config_php_handler->get('dbport'), + defined('PHPBB_DB_NEW_LINK') && PHPBB_DB_NEW_LINK + ); + } + + return $this->dbal_connection; + } + + /** + * Get enabled extensions. + * + * @return array enabled extensions + */ + protected function get_installed_extensions() + { + $db = $this->get_dbal_connection(); + $extension_table = $this->config_php_handler->get('table_prefix') . 'ext'; + + $sql = 'SELECT * + FROM ' . $extension_table . ' + WHERE ext_active = 1'; + + $result = $db->sql_query($sql); + $rows = $db->sql_fetchrowset($result); + $db->sql_freeresult($result); + + $exts = array(); + foreach ($rows as $row) + { + $exts[$row['ext_name']] = $this->phpbb_root_path . 'ext/' . $row['ext_name'] . '/'; + } + + return $exts; + } + + /** + * Create the ContainerBuilder object + * + * @param array $extensions Array of Container extension objects + * @return ContainerBuilder object + */ + protected function create_container(array $extensions) + { + $container = new ContainerBuilder(); + + foreach ($extensions as $extension) + { + $container->registerExtension($extension); + $container->loadFromExtension($extension->getAlias()); + } + + return $container; + } + + /** + * Inject the customs parameters into the container + */ + protected function inject_custom_parameters() + { + if ($this->custom_parameters === null) + { + $this->custom_parameters = array( + 'core.root_path' => $this->phpbb_root_path, + 'core.php_ext' => $this->php_ext, + ); + } + + foreach ($this->custom_parameters as $key => $value) + { + $this->container->setParameter($key, $value); + } + } + + /** + * Get the filename under which the dumped container will be stored. + * + * @return string Path for dumped container + */ + protected function get_container_filename() + { + $filename = str_replace(array('/', '.'), array('slash', 'dot'), $this->phpbb_root_path); + return $this->phpbb_root_path . 'cache/container_' . $filename . '.' . $this->php_ext; + } +} -- cgit v1.2.1 From 2db160ff87fa42ca6c47e580de9bc9d7e5cced49 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 29 Jun 2014 00:33:31 +0200 Subject: [ticket/12775] Rename config_php to config_php_file PHPBB3-12775 --- phpBB/phpbb/di/container_builder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/di/container_builder.php') diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index 426c411e07..355d975a5f 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -108,11 +108,11 @@ class container_factory /** * Constructor * - * @param \phpbb\config_php $config_php_handler + * @param \phpbb\config_php_file $config_php_handler * @param string $phpbb_root_path Path to the phpbb includes directory. * @param string $php_ext php file extension */ - function __construct(\phpbb\config_php $config_php_handler, $phpbb_root_path, $php_ext) + function __construct(\phpbb\config_php_file $config_php_handler, $phpbb_root_path, $php_ext) { $this->config_php_handler = $config_php_handler; $this->phpbb_root_path = $phpbb_root_path; -- cgit v1.2.1 From f2e8e928c08809202b1abf5668a46e3d9e735c38 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 29 Jun 2014 00:35:46 +0200 Subject: [ticket/12775] Fix container_builder PHPBB3-12775 --- phpBB/phpbb/di/container_builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/di/container_builder.php') diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index 355d975a5f..f78b9e60f8 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -16,7 +16,7 @@ namespace phpbb\di; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Dumper\PhpDumper; -class container_factory +class container_builder { /** @var string phpBB Root Path */ protected $phpbb_root_path; -- cgit v1.2.1 From 98e8be966bd8174c2a3f4e8fb80167b23573441f Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 29 Jun 2014 21:47:00 +0200 Subject: [ticket/12775] Fix comments PHPBB3-12775 --- phpBB/phpbb/di/container_builder.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/phpbb/di/container_builder.php') diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index f78b9e60f8..fbbe736e47 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -273,7 +273,6 @@ class container_builder */ protected function dump_container($container_filename) { - // Lastly, we create our cached container class $dumper = new PhpDumper($this->container); $cached_container_dump = $dumper->dump(array( 'class' => 'phpbb_cache_container', -- cgit v1.2.1 From ed812a9dfb59b1eb83263adbaa52723ff826a791 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 29 Jun 2014 21:58:17 +0200 Subject: [ticket/12775] Move phpbb_convert_30_dbms_to_31 into the config file class PHPBB3-12775 --- phpBB/phpbb/di/container_builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/di/container_builder.php') diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index fbbe736e47..95b82b26c7 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -302,7 +302,7 @@ class container_builder { if ($this->dbal_connection === null) { - $dbal_driver_class = phpbb_convert_30_dbms_to_31($this->config_php_handler->get('dbms')); + $dbal_driver_class = $this->config_php_handler->convert_30_dbms_to_31($this->config_php_handler->get('dbms')); $this->dbal_connection = new $dbal_driver_class(); $this->dbal_connection->sql_connect( $this->config_php_handler->get('dbhost'), -- cgit v1.2.1 From 35c0b6d77ac1f42c1e76b7c15469b025cd50845e Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 30 Jun 2014 00:51:28 +0200 Subject: [ticket/12775] Fix doc blocks in the container builder PHPBB3-12775 --- phpBB/phpbb/di/container_builder.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'phpBB/phpbb/di/container_builder.php') diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index 95b82b26c7..4b6fb6d20b 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -42,42 +42,42 @@ class container_builder protected $installed_exts = null; /** - * Indicates if the php config file should be injecting into the container (default to true). + * Indicates whether the php config file should be injected into the container (default to true). * * @var bool */ protected $inject_config = true; /** - * Indicates if the extensions should be used (default to true). + * Indicates whether extensions should be used (default to true). * * @var bool */ protected $use_extensions = true; /** - * Defines a custom path to find the configuration of the container. + * Defines a custom path to find the configuration of the container (default to $this->phpbb_root_path . 'config') * * @var string */ protected $config_path = null; /** - * Indicates if the phpBB compile pass have to be used (default to true). + * Indicates whether the phpBB compile pass should be used (default to true). * * @var bool */ protected $use_custom_pass = true; /** - * Indicates if the kernel compile pass have to be used (default to true). + * Indicates whether the kernel compile pass should be used (default to true). * * @var bool */ protected $use_kernel_pass = true; /** - * Indicates if a dump container should be used (default to true). + * Indicates whether the container should be dumped to the filesystem (default to true). * * If DEBUG_CONTAINER is set this option is ignored and a new container is build. * @@ -105,16 +105,21 @@ class container_builder */ protected $custom_parameters = null; + /** + * @var \phpbb\config_php_file + */ + protected $config_php_file; + /** * Constructor * - * @param \phpbb\config_php_file $config_php_handler + * @param \phpbb\config_php_file $config_php_file * @param string $phpbb_root_path Path to the phpbb includes directory. * @param string $php_ext php file extension */ - function __construct(\phpbb\config_php_file $config_php_handler, $phpbb_root_path, $php_ext) + function __construct(\phpbb\config_php_file $config_php_file, $phpbb_root_path, $php_ext) { - $this->config_php_handler = $config_php_handler; + $this->config_php_file = $config_php_file; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; } -- cgit v1.2.1 From 6c57fbecac3aff2341fc874a911b3f296252ee3e Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 30 Jun 2014 01:05:55 +0200 Subject: [ticket/12775] Rename config_php_handler to config_php_file container_builder PHPBB3-12775 --- phpBB/phpbb/di/container_builder.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'phpBB/phpbb/di/container_builder.php') diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index 4b6fb6d20b..9cf29c8929 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -153,7 +153,7 @@ class container_builder if ($this->inject_config) { - $container_extensions[] = new \phpbb\di\extension\config($this->config_php_handler); + $container_extensions[] = new \phpbb\di\extension\config($this->config_php_file); } $this->container = $this->create_container($container_extensions); @@ -181,7 +181,7 @@ class container_builder } } - $this->container->set('config.php', $this->config_php_handler); + $this->container->set('config.php', $this->config_php_file); // Frozen container, we can't modify either the services or the parameters //$this->inject_dbal(); @@ -307,14 +307,14 @@ class container_builder { if ($this->dbal_connection === null) { - $dbal_driver_class = $this->config_php_handler->convert_30_dbms_to_31($this->config_php_handler->get('dbms')); + $dbal_driver_class = $this->config_php_file->convert_30_dbms_to_31($this->config_php_file->get('dbms')); $this->dbal_connection = new $dbal_driver_class(); $this->dbal_connection->sql_connect( - $this->config_php_handler->get('dbhost'), - $this->config_php_handler->get('dbuser'), - $this->config_php_handler->get('dbpasswd'), - $this->config_php_handler->get('dbname'), - $this->config_php_handler->get('dbport'), + $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'), defined('PHPBB_DB_NEW_LINK') && PHPBB_DB_NEW_LINK ); } @@ -330,7 +330,7 @@ class container_builder protected function get_installed_extensions() { $db = $this->get_dbal_connection(); - $extension_table = $this->config_php_handler->get('table_prefix') . 'ext'; + $extension_table = $this->config_php_file->get('table_prefix') . 'ext'; $sql = 'SELECT * FROM ' . $extension_table . ' -- cgit v1.2.1 From 5b11ee8c97e88367fc39b90b6a871e3bf16f7d1e Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 4 Jul 2014 21:36:25 +0200 Subject: [ticket/12775] Inject the connection when created in the container PHPBB3-12775 --- phpBB/phpbb/di/container_builder.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/di/container_builder.php') diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index 9cf29c8929..65db92ada0 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -183,8 +183,7 @@ class container_builder $this->container->set('config.php', $this->config_php_file); - // Frozen container, we can't modify either the services or the parameters - //$this->inject_dbal(); + $this->inject_dbal(); return $this->container; } @@ -294,7 +293,7 @@ class container_builder { if ($this->dbal_connection !== null) { - $this->container->set('dbal.conn', $this->dbal_connection); + $this->container->get('dbal.conn')->set_driver($this->dbal_connection); } } -- cgit v1.2.1 From e2cbaf4f1a0b0ddcba45babbe922076ff149a83d Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 7 Jul 2014 00:08:34 +0200 Subject: [ticket/12775] Add the definition of dbal.conn in fixtures/config/services.yml PHPBB3-12775 --- phpBB/phpbb/di/container_builder.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/di/container_builder.php') diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index 65db92ada0..ab10073013 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -183,7 +183,10 @@ class container_builder $this->container->set('config.php', $this->config_php_file); - $this->inject_dbal(); + if ($this->compile_container) + { + $this->inject_dbal(); + } return $this->container; } -- cgit v1.2.1 From 1ee7df57ae9ab0a111a1a29a8b8b2a1d5a1d42e2 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Tue, 15 Jul 2014 22:58:28 +0200 Subject: [ticket/12855] Dump the container based on DEBUG_CONTAINER instead of DEBUG PHPBB3-12855 --- phpBB/phpbb/di/container_builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/di/container_builder.php') diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index ab10073013..553b723cc8 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -175,7 +175,7 @@ class container_builder $this->container->compile(); } - if ($this->dump_container && !defined('DEBUG')) + if ($this->dump_container && !defined('DEBUG_CONTAINER')) { $this->dump_container($container_filename); } -- cgit v1.2.1 From c988b98ac65b726f02dd61de93c911064e0cfe66 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 13 Sep 2014 14:05:31 +0200 Subject: [ticket/13061] Replace the service event.subscriber_loader by a compiler pass PHPBB3-13061 --- phpBB/phpbb/di/container_builder.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/di/container_builder.php') diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index 553b723cc8..638c13e86d 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -15,6 +15,7 @@ namespace phpbb\di; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Dumper\PhpDumper; +use Symfony\Component\HttpKernel\DependencyInjection\RegisterListenersPass; class container_builder { @@ -160,11 +161,13 @@ class container_builder if ($this->use_custom_pass) { + // Symfony Kernel Listeners $this->container->addCompilerPass(new \phpbb\di\pass\collection_pass()); + $this->container->addCompilerPass(new RegisterListenersPass('dispatcher', 'event.listener_listener', 'event.listener')); if ($this->use_kernel_pass) { - $this->container->addCompilerPass(new \phpbb\di\pass\kernel_pass()); + $this->container->addCompilerPass(new RegisterListenersPass('dispatcher')); } } -- cgit v1.2.1 From 08a6f663dea6f1d634f0de14128e8eddd3106807 Mon Sep 17 00:00:00 2001 From: Wardormeur Date: Sun, 31 May 2015 11:57:03 +0200 Subject: [ticket/13903] Replacing regexp path naming for container by md5. Replacement of the path creation based on a blacklist by a md5 filename to support broader configurations PHPBB3-13903 --- phpBB/phpbb/di/container_builder.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'phpBB/phpbb/di/container_builder.php') diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index 638c13e86d..a214356ac3 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -399,7 +399,6 @@ class container_builder */ protected function get_container_filename() { - $filename = str_replace(array('/', '.'), array('slash', 'dot'), $this->phpbb_root_path); - return $this->phpbb_root_path . 'cache/container_' . $filename . '.' . $this->php_ext; + return $this->phpbb_root_path . 'cache/container_' . md5($this->phpbb_root_path) . '.' . $this->php_ext; } } -- cgit v1.2.1 From 14fd750b087c7c9e31f9701bb08ced08db964d12 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 28 Dec 2016 18:15:17 +0100 Subject: [ticket/14957] Do not cache database config entries PHPBB3-14957 --- phpBB/phpbb/di/container_builder.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'phpBB/phpbb/di/container_builder.php') diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index a214356ac3..9801b817d6 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -185,6 +185,7 @@ class container_builder } $this->container->set('config.php', $this->config_php_file); + $this->inject_dbal_driver(); if ($this->compile_container) { @@ -303,6 +304,17 @@ class container_builder } } + /** + * Inject the dbal connection driver into container + */ + protected function inject_dbal_driver() + { + if (!empty($this->config_php_file->get_all())) + { + $this->container->set('dbal.conn.driver', $this->get_dbal_connection()); + } + } + /** * Get DB connection. * @@ -320,6 +332,7 @@ class container_builder $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 ); } -- cgit v1.2.1 From ff411ee81bc12574138577a5bb4b0cbc9004b00e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 3 Jan 2017 21:53:14 +0100 Subject: [ticket/14957] Do not use method return in write context Fix for PHP 5.3.x compatibility. PHPBB3-14957 --- phpBB/phpbb/di/container_builder.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/di/container_builder.php') diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index 9801b817d6..5f3aa685bf 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -309,7 +309,8 @@ class container_builder */ protected function inject_dbal_driver() { - if (!empty($this->config_php_file->get_all())) + $config_data = $this->config_php_file->get_all(); + if (!empty($config_data)) { $this->container->set('dbal.conn.driver', $this->get_dbal_connection()); } -- cgit v1.2.1