From deb556fbf05eeec447234f15f4eada58526f0b81 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Tue, 4 Jul 2017 16:39:18 +0200 Subject: [ticket/15258] Adds a method to get a service by class in service_collection PHPBB3-15258 --- phpBB/phpbb/di/service_collection.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'phpBB/phpbb/di') diff --git a/phpBB/phpbb/di/service_collection.php b/phpBB/phpbb/di/service_collection.php index 8e9175e204..8c1c172e36 100644 --- a/phpBB/phpbb/di/service_collection.php +++ b/phpBB/phpbb/di/service_collection.php @@ -103,4 +103,35 @@ class service_collection extends \ArrayObject { return $this->service_classes; } + + /** + * Returns the service associated to a class + * + * @return mixed + * @throw \RuntimeException if the + */ + public function get_by_class($class) + { + $service_id = null; + + foreach ($this->service_classes as $id => $service_class) + { + if ($service_class === $class) + { + if ($service_id !== null) + { + throw new \RuntimeException('More than one service definitions found for class "'.$class.'" in collection.'); + } + + $service_id = $id; + } + } + + if ($service_id === null) + { + throw new \RuntimeException('No service found for class "'.$class.'" in collection.'); + } + + return $this->offsetGet($service_id); + } } -- cgit v1.2.1 From b4d4336ef4043a5b3381a9e70d3bbc6bc6732d07 Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Mon, 18 Jun 2018 20:42:16 +0200 Subject: [ticket/12627] Add debug.sql_explain parameter PHPBB3-12627 --- phpBB/phpbb/di/extension/container_configuration.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/phpbb/di') diff --git a/phpBB/phpbb/di/extension/container_configuration.php b/phpBB/phpbb/di/extension/container_configuration.php index 4585d6509e..7d1a1abe5e 100644 --- a/phpBB/phpbb/di/extension/container_configuration.php +++ b/phpBB/phpbb/di/extension/container_configuration.php @@ -35,6 +35,7 @@ class container_configuration implements ConfigurationInterface ->addDefaultsIfNotSet() ->children() ->booleanNode('exceptions')->defaultValue(false)->end() + ->booleanNode('sql_explain')->defaultValue(false)->end() ->end() ->end() ->arrayNode('twig') -- cgit v1.2.1 From 139eb17bb729763ab670fb239c77db02e29920f6 Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Mon, 18 Jun 2018 20:35:01 +0200 Subject: [ticket/12624] Add debug.load_time parameter PHPBB3-12624 --- phpBB/phpbb/di/extension/container_configuration.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/phpbb/di') diff --git a/phpBB/phpbb/di/extension/container_configuration.php b/phpBB/phpbb/di/extension/container_configuration.php index 7d1a1abe5e..971b6fb523 100644 --- a/phpBB/phpbb/di/extension/container_configuration.php +++ b/phpBB/phpbb/di/extension/container_configuration.php @@ -35,6 +35,7 @@ class container_configuration implements ConfigurationInterface ->addDefaultsIfNotSet() ->children() ->booleanNode('exceptions')->defaultValue(false)->end() + ->booleanNode('load_time')->defaultValue(false)->end() ->booleanNode('sql_explain')->defaultValue(false)->end() ->end() ->end() -- cgit v1.2.1 From 1609fa292d738e200643b098d8a94ce63b95a6b7 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 12 Sep 2018 13:57:34 +0200 Subject: [ticket/15746] Update symfony to latest on master Also fixed incorrect creation of dumped container (Container instead of ContainerBuilder). PHPBB3-15746 --- phpBB/phpbb/di/container_builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/di') diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index 8c1ce8bde2..f2708e6de6 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -481,7 +481,7 @@ class container_builder $cached_container_dump = $dumper->dump(array( 'class' => 'phpbb_cache_container', - 'base_class' => 'Symfony\\Component\\DependencyInjection\\ContainerBuilder', + 'base_class' => 'Symfony\\Component\\DependencyInjection\\Container', )); $cache->write($cached_container_dump, $this->container->getResources()); -- cgit v1.2.1 From 432482160d55dd1f65b568abeb30f789a27a89c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Sat, 1 Sep 2018 01:09:22 +0200 Subject: [ticket/12623] Add allow_install_dir PHPBB3-12623 --- phpBB/phpbb/di/extension/container_configuration.php | 1 + phpBB/phpbb/di/extension/core.php | 2 ++ 2 files changed, 3 insertions(+) (limited to 'phpBB/phpbb/di') diff --git a/phpBB/phpbb/di/extension/container_configuration.php b/phpBB/phpbb/di/extension/container_configuration.php index 971b6fb523..dfcbfbc729 100644 --- a/phpBB/phpbb/di/extension/container_configuration.php +++ b/phpBB/phpbb/di/extension/container_configuration.php @@ -31,6 +31,7 @@ class container_configuration implements ConfigurationInterface $rootNode ->children() ->booleanNode('require_dev_dependencies')->defaultValue(false)->end() + ->booleanNode('allow_install_dir')->defaultValue(false)->end() ->arrayNode('debug') ->addDefaultsIfNotSet() ->children() diff --git a/phpBB/phpbb/di/extension/core.php b/phpBB/phpbb/di/extension/core.php index 67150f0103..7b5a286b40 100644 --- a/phpBB/phpbb/di/extension/core.php +++ b/phpBB/phpbb/di/extension/core.php @@ -71,6 +71,8 @@ class core extends Extension } } + $container->setParameter('allow_install_dir', $config['allow_install_dir']); + // Set the Twig options if defined in the environment $definition = $container->getDefinition('template.twig.environment'); $twig_environment_options = $definition->getArgument(static::TWIG_OPTIONS_POSITION); -- cgit v1.2.1 From 4f402465bf41c88876a499cacfc6bdc1762dfe44 Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Wed, 1 Aug 2018 15:05:10 +0200 Subject: [ticket/12628] Introduce debug.memory Also fix one debug.sql_explain missing from the previous PR PHPBB3-12628 --- phpBB/phpbb/di/extension/container_configuration.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/phpbb/di') diff --git a/phpBB/phpbb/di/extension/container_configuration.php b/phpBB/phpbb/di/extension/container_configuration.php index dfcbfbc729..c64f47c716 100644 --- a/phpBB/phpbb/di/extension/container_configuration.php +++ b/phpBB/phpbb/di/extension/container_configuration.php @@ -38,6 +38,7 @@ class container_configuration implements ConfigurationInterface ->booleanNode('exceptions')->defaultValue(false)->end() ->booleanNode('load_time')->defaultValue(false)->end() ->booleanNode('sql_explain')->defaultValue(false)->end() + ->booleanNode('memory')->defaultValue(false)->end() ->end() ->end() ->arrayNode('twig') -- cgit v1.2.1 From 303b823847d23edf381203bddb7af58a3ad68173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Sat, 1 Sep 2018 01:16:57 +0200 Subject: [ticket/12636] Add log.session_errors PHPBB3-12636 --- phpBB/phpbb/di/extension/container_configuration.php | 6 ++++++ phpBB/phpbb/di/extension/core.php | 6 ++++++ 2 files changed, 12 insertions(+) (limited to 'phpBB/phpbb/di') diff --git a/phpBB/phpbb/di/extension/container_configuration.php b/phpBB/phpbb/di/extension/container_configuration.php index c64f47c716..25e0f8a193 100644 --- a/phpBB/phpbb/di/extension/container_configuration.php +++ b/phpBB/phpbb/di/extension/container_configuration.php @@ -49,6 +49,12 @@ class container_configuration implements ConfigurationInterface ->booleanNode('enable_debug_extension')->defaultValue(false)->end() ->end() ->end() + ->arrayNode('log') + ->addDefaultsIfNotSet() + ->children() + ->booleanNode('session_errors')->defaultValue(false)->end() + ->end() + ->end() ->end() ; return $treeBuilder; diff --git a/phpBB/phpbb/di/extension/core.php b/phpBB/phpbb/di/extension/core.php index 7b5a286b40..213e3a5890 100644 --- a/phpBB/phpbb/di/extension/core.php +++ b/phpBB/phpbb/di/extension/core.php @@ -99,6 +99,12 @@ class core extends Extension { $container->setParameter('debug.' . $name, $value); } + + // Set the log options + foreach ($config['log'] as $name => $value) + { + $container->setParameter('log.' . $name, $value); + } } /** -- cgit v1.2.1 From a702142a3483e0d80352e74d238938e6f01eaa2d Mon Sep 17 00:00:00 2001 From: rubencm Date: Thu, 13 Sep 2018 14:53:01 +0000 Subject: [ticket/12636] Rename log.session_errors to session.log_errors PHPBB3-12636 --- phpBB/phpbb/di/extension/container_configuration.php | 4 ++-- phpBB/phpbb/di/extension/core.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/di') diff --git a/phpBB/phpbb/di/extension/container_configuration.php b/phpBB/phpbb/di/extension/container_configuration.php index 25e0f8a193..131ec70c8d 100644 --- a/phpBB/phpbb/di/extension/container_configuration.php +++ b/phpBB/phpbb/di/extension/container_configuration.php @@ -49,10 +49,10 @@ class container_configuration implements ConfigurationInterface ->booleanNode('enable_debug_extension')->defaultValue(false)->end() ->end() ->end() - ->arrayNode('log') + ->arrayNode('session') ->addDefaultsIfNotSet() ->children() - ->booleanNode('session_errors')->defaultValue(false)->end() + ->booleanNode('log_errors')->defaultValue(false)->end() ->end() ->end() ->end() diff --git a/phpBB/phpbb/di/extension/core.php b/phpBB/phpbb/di/extension/core.php index 213e3a5890..0497c90e2a 100644 --- a/phpBB/phpbb/di/extension/core.php +++ b/phpBB/phpbb/di/extension/core.php @@ -101,9 +101,9 @@ class core extends Extension } // Set the log options - foreach ($config['log'] as $name => $value) + foreach ($config['session'] as $name => $value) { - $container->setParameter('log.' . $name, $value); + $container->setParameter('session.' . $name, $value); } } -- cgit v1.2.1 From ba088f6bdc2d8dcf48f93646b13108c64124ba1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Sat, 1 Sep 2018 01:47:10 +0200 Subject: [ticket/12629] Add debug.errors_show PHPBB3-12629 --- phpBB/phpbb/di/extension/container_configuration.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/phpbb/di') diff --git a/phpBB/phpbb/di/extension/container_configuration.php b/phpBB/phpbb/di/extension/container_configuration.php index 131ec70c8d..9f8cf34311 100644 --- a/phpBB/phpbb/di/extension/container_configuration.php +++ b/phpBB/phpbb/di/extension/container_configuration.php @@ -39,6 +39,7 @@ class container_configuration implements ConfigurationInterface ->booleanNode('load_time')->defaultValue(false)->end() ->booleanNode('sql_explain')->defaultValue(false)->end() ->booleanNode('memory')->defaultValue(false)->end() + ->booleanNode('errors_show')->defaultValue(false)->end() ->end() ->end() ->arrayNode('twig') -- cgit v1.2.1 From 6643c904d52563e26e8a92338c45f38cd5e0167f Mon Sep 17 00:00:00 2001 From: rubencm Date: Thu, 13 Sep 2018 14:40:47 +0000 Subject: [ticket/12629] Rename errors_show to show_errors PHPBB3-12629 --- phpBB/phpbb/di/extension/container_configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/di') diff --git a/phpBB/phpbb/di/extension/container_configuration.php b/phpBB/phpbb/di/extension/container_configuration.php index 9f8cf34311..57e7ef6ca6 100644 --- a/phpBB/phpbb/di/extension/container_configuration.php +++ b/phpBB/phpbb/di/extension/container_configuration.php @@ -39,7 +39,7 @@ class container_configuration implements ConfigurationInterface ->booleanNode('load_time')->defaultValue(false)->end() ->booleanNode('sql_explain')->defaultValue(false)->end() ->booleanNode('memory')->defaultValue(false)->end() - ->booleanNode('errors_show')->defaultValue(false)->end() + ->booleanNode('show_errors')->defaultValue(false)->end() ->end() ->end() ->arrayNode('twig') -- cgit v1.2.1 From 9c1baf0fd774c8fa30bd5192fd8d097996b35e56 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 5 May 2019 17:23:16 +0200 Subject: [ticket/15987] Add container extension to support tables "array access" PHPBB3-15987 --- phpBB/phpbb/di/container_builder.php | 5 +++- phpBB/phpbb/di/extension/tables.php | 56 ++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 phpBB/phpbb/di/extension/tables.php (limited to 'phpBB/phpbb/di') diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index f2708e6de6..552b8c7a95 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -158,7 +158,10 @@ class container_builder } else { - $this->container_extensions = array(new extension\core($this->get_config_path())); + $this->container_extensions = [ + new extension\core($this->get_config_path()), + new extension\tables(), + ]; if ($this->use_extensions) { diff --git a/phpBB/phpbb/di/extension/tables.php b/phpBB/phpbb/di/extension/tables.php new file mode 100644 index 0000000000..99655dda3d --- /dev/null +++ b/phpBB/phpbb/di/extension/tables.php @@ -0,0 +1,56 @@ + + * @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\extension; + +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\HttpKernel\DependencyInjection\Extension; + +/** + * Container tables extension + */ +class tables extends Extension +{ + /** + * Loads a specific configuration. + * + * @param array $configs An array of configuration values + * @param ContainerBuilder $container A ContainerBuilder instance + * + * @throws \InvalidArgumentException When provided tag is not defined in this extension + */ + public function load(array $configs, ContainerBuilder $container) + { + if (!$container->hasParameter('tables')) + return; + + $tables = $container->getParameter('tables'); + + foreach ($tables as $table_name => $table_value) + { + $container->setParameter('tables.' . $table_name, $table_value); + } + } + + /** + * Returns the recommended alias to use in XML. + * + * This alias is also the mandatory prefix to use when using YAML. + * + * @return string The alias + */ + public function getAlias() + { + return 'tables'; + } +} -- cgit v1.2.1 From 61fa4f006aa00eb67dd4df8d21f426ce7e53962c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 5 May 2019 18:20:30 +0200 Subject: [ticket/15987] Add missing paranthesis PHPBB3-15987 --- phpBB/phpbb/di/extension/tables.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/phpbb/di') diff --git a/phpBB/phpbb/di/extension/tables.php b/phpBB/phpbb/di/extension/tables.php index 99655dda3d..ff545750b7 100644 --- a/phpBB/phpbb/di/extension/tables.php +++ b/phpBB/phpbb/di/extension/tables.php @@ -32,7 +32,9 @@ class tables extends Extension public function load(array $configs, ContainerBuilder $container) { if (!$container->hasParameter('tables')) + { return; + } $tables = $container->getParameter('tables'); -- cgit v1.2.1 From d72498a9c3006210c49cb1690d079d52593db127 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 14 May 2019 21:20:51 +0200 Subject: [ticket/15987] Go back to previous table definition type This will still allow using the 'tables' parameter array but will also ensure full backward compatibility and compatibility with extensions that will add more tables to the 'tables' array. PHPBB3-15987 --- phpBB/phpbb/di/container_builder.php | 4 +++- phpBB/phpbb/di/extension/tables.php | 29 +++++++++++++++-------------- 2 files changed, 18 insertions(+), 15 deletions(-) (limited to 'phpBB/phpbb/di') diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index 552b8c7a95..70ceb9b5e3 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -160,7 +160,6 @@ class container_builder { $this->container_extensions = [ new extension\core($this->get_config_path()), - new extension\tables(), ]; if ($this->use_extensions) @@ -168,6 +167,9 @@ class container_builder $this->load_extensions(); } + // Add tables extension after all extensions + $this->container_extensions[] = new extension\tables(); + // Inject the config if ($this->config_php_file) { diff --git a/phpBB/phpbb/di/extension/tables.php b/phpBB/phpbb/di/extension/tables.php index ff545750b7..40684b6038 100644 --- a/phpBB/phpbb/di/extension/tables.php +++ b/phpBB/phpbb/di/extension/tables.php @@ -22,26 +22,27 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension; class tables extends Extension { /** - * Loads a specific configuration. - * - * @param array $configs An array of configuration values - * @param ContainerBuilder $container A ContainerBuilder instance - * - * @throws \InvalidArgumentException When provided tag is not defined in this extension + * {@inheritDoc} */ public function load(array $configs, ContainerBuilder $container) { - if (!$container->hasParameter('tables')) - { - return; - } + // Tables is a reserved parameter and will be overwritten at all times + $tables = []; - $tables = $container->getParameter('tables'); - - foreach ($tables as $table_name => $table_value) + // Add access via 'tables' parameter to acquire array with all tables + $parameterBag = $container->getParameterBag(); + $parameters = $parameterBag->all(); + foreach ($parameters as $parameter_name => $parameter_value) { - $container->setParameter('tables.' . $table_name, $table_value); + if (!preg_match('/tables\.(.+)/', $parameter_name, $matches)) + { + continue; + } + + $tables[$matches[1]] = $parameter_value; } + + $container->setParameter('tables', $tables); } /** -- cgit v1.2.1 From 3e22a2eebdc29ae6f2dc828f0886888fb2d385a8 Mon Sep 17 00:00:00 2001 From: mrgoldy Date: Sun, 10 Nov 2019 22:28:53 +0100 Subject: [ticket/16206] Remove offsetExists and set non-NULL value PHPBB3-16206 --- phpBB/phpbb/di/service_collection.php | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'phpBB/phpbb/di') diff --git a/phpBB/phpbb/di/service_collection.php b/phpBB/phpbb/di/service_collection.php index 8c1c172e36..6298670c42 100644 --- a/phpBB/phpbb/di/service_collection.php +++ b/phpBB/phpbb/di/service_collection.php @@ -49,21 +49,6 @@ class service_collection extends \ArrayObject return new service_collection_iterator($this); } - // Because of a PHP issue we have to redefine offsetExists - // (even with a call to the parent): - // https://bugs.php.net/bug.php?id=66834 - // https://bugs.php.net/bug.php?id=67067 - // But it triggers a sniffer issue that we have to skip - // @codingStandardsIgnoreStart - /** - * {@inheritdoc} - */ - public function offsetExists($index) - { - return parent::offsetExists($index); - } - // @codingStandardsIgnoreEnd - /** * {@inheritdoc} */ @@ -76,11 +61,11 @@ class service_collection extends \ArrayObject * Add a service to the collection * * @param string $name The service name - * @return null + * @return void */ public function add($name) { - $this->offsetSet($name, null); + $this->offsetSet($name, false); } /** -- cgit v1.2.1