From 98cb70f5d2e42dafa48413713cc60ddd881c54c6 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 23 Jun 2015 14:31:18 +0200 Subject: [PATCH 1/9] [ticket/13961] Move service_collection to di/service_collection namespace PHPBB3-13961 --- phpBB/config/default/container/services_auth.yml | 2 +- phpBB/config/default/container/services_avatar.yml | 2 +- phpBB/config/default/container/services_captcha.yml | 2 +- phpBB/config/default/container/services_console.yml | 2 +- phpBB/config/default/container/services_cron.yml | 2 +- phpBB/config/default/container/services_migrator.yml | 2 +- .../config/default/container/services_mimetype_guesser.yml | 2 +- phpBB/config/default/container/services_notification.yml | 6 +++--- phpBB/config/default/container/services_password.yml | 2 +- phpBB/config/default/container/services_profilefield.yml | 2 +- phpBB/config/default/container/services_twig.yml | 2 +- phpBB/includes/acp/acp_profile.php | 2 +- phpBB/phpbb/auth/provider/oauth/oauth.php | 6 +++--- phpBB/phpbb/auth/provider_collection.php | 2 +- phpBB/phpbb/captcha/factory.php | 6 +++--- phpBB/phpbb/console/application.php | 4 ++-- .../di/{ => service_collection}/service_collection.php | 2 +- .../service_collection_iterator.php | 6 +++--- phpBB/phpbb/passwords/manager.php | 2 +- phpBB/phpbb/profilefields/manager.php | 6 +++--- tests/functions/user_delete_test.php | 2 +- tests/session/garbage_collection_test.php | 2 +- 22 files changed, 33 insertions(+), 33 deletions(-) rename phpBB/phpbb/di/{ => service_collection}/service_collection.php (97%) rename phpBB/phpbb/di/{ => service_collection}/service_collection_iterator.php (81%) diff --git a/phpBB/config/default/container/services_auth.yml b/phpBB/config/default/container/services_auth.yml index 88a90ca2d6..28b98a98b7 100644 --- a/phpBB/config/default/container/services_auth.yml +++ b/phpBB/config/default/container/services_auth.yml @@ -69,7 +69,7 @@ services: # ----- OAuth services providers ----- auth.provider.oauth.service_collection: - class: phpbb\di\service_collection + class: phpbb\di\service_collection\service_collection arguments: - @service_container tags: diff --git a/phpBB/config/default/container/services_avatar.yml b/phpBB/config/default/container/services_avatar.yml index c74bef3d66..cd5b0756c6 100644 --- a/phpBB/config/default/container/services_avatar.yml +++ b/phpBB/config/default/container/services_avatar.yml @@ -7,7 +7,7 @@ services: # ----- Avatar drivers ----- avatar.driver_collection: - class: phpbb\di\service_collection + class: phpbb\di\service_collection\service_collection arguments: - @service_container tags: diff --git a/phpBB/config/default/container/services_captcha.yml b/phpBB/config/default/container/services_captcha.yml index e3f617e909..9e4150b094 100644 --- a/phpBB/config/default/container/services_captcha.yml +++ b/phpBB/config/default/container/services_captcha.yml @@ -8,7 +8,7 @@ services: # ----- Captcha plugins ----- # Scope MUST be prototype for all the plugins to work. captcha.plugins.service_collection: - class: phpbb\di\service_collection + class: phpbb\di\service_collection\service_collection arguments: - @service_container tags: diff --git a/phpBB/config/default/container/services_console.yml b/phpBB/config/default/container/services_console.yml index f0ae6c8ab4..36e2bd5729 100644 --- a/phpBB/config/default/container/services_console.yml +++ b/phpBB/config/default/container/services_console.yml @@ -1,6 +1,6 @@ services: console.command_collection: - class: phpbb\di\service_collection + class: phpbb\di\service_collection\service_collection arguments: - @service_container tags: diff --git a/phpBB/config/default/container/services_cron.yml b/phpBB/config/default/container/services_cron.yml index c5b88df181..cc3c70c542 100644 --- a/phpBB/config/default/container/services_cron.yml +++ b/phpBB/config/default/container/services_cron.yml @@ -15,7 +15,7 @@ services: # ----- Cron tasks ----- cron.task_collection: - class: phpbb\di\service_collection + class: phpbb\di\service_collection\service_collection arguments: - @service_container tags: diff --git a/phpBB/config/default/container/services_migrator.yml b/phpBB/config/default/container/services_migrator.yml index 01bd7d3a11..8c81aec8b3 100644 --- a/phpBB/config/default/container/services_migrator.yml +++ b/phpBB/config/default/container/services_migrator.yml @@ -19,7 +19,7 @@ services: # ----- Migrator's tools ----- migrator.tool_collection: - class: phpbb\di\service_collection + class: phpbb\di\service_collection\service_collection arguments: - @service_container tags: diff --git a/phpBB/config/default/container/services_mimetype_guesser.yml b/phpBB/config/default/container/services_mimetype_guesser.yml index 2e89ed3c1f..f22a41613a 100644 --- a/phpBB/config/default/container/services_mimetype_guesser.yml +++ b/phpBB/config/default/container/services_mimetype_guesser.yml @@ -1,6 +1,6 @@ services: mimetype.guesser_collection: - class: phpbb\di\service_collection + class: phpbb\di\service_collection\service_collection arguments: - @service_container tags: diff --git a/phpBB/config/default/container/services_notification.yml b/phpBB/config/default/container/services_notification.yml index c3bbcddfa6..896b93f75b 100644 --- a/phpBB/config/default/container/services_notification.yml +++ b/phpBB/config/default/container/services_notification.yml @@ -20,7 +20,7 @@ services: # ----- Notification's types ----- # Scope MUST be prototype for all the plugins to work. notification.type_collection: - class: phpbb\di\service_collection + class: phpbb\di\service_collection\service_collection arguments: - @service_container tags: @@ -351,11 +351,11 @@ services: - %tables.user_notifications% tags: - { name: notification.type } - + # ----- Notification's methods ----- # Scope MUST be prototype for all the plugins to work. notification.method_collection: - class: phpbb\di\service_collection + class: phpbb\di\service_collection\service_collection arguments: - @service_container tags: diff --git a/phpBB/config/default/container/services_password.yml b/phpBB/config/default/container/services_password.yml index cb45ec3d42..22530f33d6 100644 --- a/phpBB/config/default/container/services_password.yml +++ b/phpBB/config/default/container/services_password.yml @@ -18,7 +18,7 @@ services: # ----- Password's drivers ----- passwords.driver_collection: - class: phpbb\di\service_collection + class: phpbb\di\service_collection\service_collection arguments: - @service_container tags: diff --git a/phpBB/config/default/container/services_profilefield.yml b/phpBB/config/default/container/services_profilefield.yml index 5ccfef9148..9bbc0be4c9 100644 --- a/phpBB/config/default/container/services_profilefield.yml +++ b/phpBB/config/default/container/services_profilefield.yml @@ -21,7 +21,7 @@ services: # ----- Profile fields types ----- profilefields.type_collection: - class: phpbb\di\service_collection + class: phpbb\di\service_collection\service_collection arguments: - @service_container tags: diff --git a/phpBB/config/default/container/services_twig.yml b/phpBB/config/default/container/services_twig.yml index 2799892376..2c5b5a8398 100644 --- a/phpBB/config/default/container/services_twig.yml +++ b/phpBB/config/default/container/services_twig.yml @@ -25,7 +25,7 @@ services: - @filesystem template.twig.extensions.collection: - class: phpbb\di\service_collection + class: phpbb\di\service_collection\service_collection arguments: - @service_container tags: diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index 146e116cfd..79feda88f1 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -27,7 +27,7 @@ class acp_profile var $lang_defs; /** - * @var \phpbb\di\service_collection + * @var \phpbb\di\service_collection\service_collection */ protected $type_collection; diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index be0fbf5831..612446a2a8 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -72,7 +72,7 @@ class oauth extends \phpbb\auth\provider\base /** * All OAuth service providers * - * @var \phpbb\di\service_collection Contains \phpbb\auth\provider\oauth\service_interface + * @var \phpbb\di\service_collection\service_collection Contains \phpbb\auth\provider\oauth\service_interface */ protected $service_providers; @@ -121,13 +121,13 @@ class oauth extends \phpbb\auth\provider\base * @param \phpbb\user $user * @param string $auth_provider_oauth_token_storage_table * @param string $auth_provider_oauth_token_account_assoc - * @param \phpbb\di\service_collection $service_providers Contains \phpbb\auth\provider\oauth\service_interface + * @param \phpbb\di\service_collection\service_collection $service_providers Contains \phpbb\auth\provider\oauth\service_interface * @param string $users_table * @param \Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container DI container * @param string $phpbb_root_path * @param string $php_ext */ - public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\passwords\manager $passwords_manager, \phpbb\request\request_interface $request, \phpbb\user $user, $auth_provider_oauth_token_storage_table, $auth_provider_oauth_token_account_assoc, \phpbb\di\service_collection $service_providers, $users_table, \Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container, $phpbb_root_path, $php_ext) + public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\passwords\manager $passwords_manager, \phpbb\request\request_interface $request, \phpbb\user $user, $auth_provider_oauth_token_storage_table, $auth_provider_oauth_token_account_assoc, \phpbb\di\service_collection\service_collection $service_providers, $users_table, \Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container, $phpbb_root_path, $php_ext) { $this->db = $db; $this->config = $config; diff --git a/phpBB/phpbb/auth/provider_collection.php b/phpBB/phpbb/auth/provider_collection.php index 8e7e9e2cc1..71da30e4c4 100644 --- a/phpBB/phpbb/auth/provider_collection.php +++ b/phpBB/phpbb/auth/provider_collection.php @@ -18,7 +18,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; /** * Collection of auth providers to be configured at container compile time. */ -class provider_collection extends \phpbb\di\service_collection +class provider_collection extends \phpbb\di\service_collection\service_collection { /** @var \phpbb\config\config phpBB Config */ protected $config; diff --git a/phpBB/phpbb/captcha/factory.php b/phpBB/phpbb/captcha/factory.php index dd44aca8bb..1357e919bb 100644 --- a/phpBB/phpbb/captcha/factory.php +++ b/phpBB/phpbb/captcha/factory.php @@ -21,7 +21,7 @@ class factory private $container; /** - * @var \phpbb\di\service_collection + * @var \phpbb\di\service_collection\service_collection */ private $plugins; @@ -29,9 +29,9 @@ class factory * Constructor * * @param \Symfony\Component\DependencyInjection\ContainerInterface $container - * @param \phpbb\di\service_collection $plugins + * @param \phpbb\di\service_collection\service_collection $plugins */ - public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container, \phpbb\di\service_collection $plugins) + public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container, \phpbb\di\service_collection\service_collection $plugins) { $this->container = $container; $this->plugins = $plugins; diff --git a/phpBB/phpbb/console/application.php b/phpBB/phpbb/console/application.php index bc4897af18..fa847cd64d 100644 --- a/phpBB/phpbb/console/application.php +++ b/phpBB/phpbb/console/application.php @@ -89,9 +89,9 @@ class application extends \Symfony\Component\Console\Application /** * Register a set of commands from the container * - * @param \phpbb\di\service_collection $command_collection The console service collection + * @param \phpbb\di\service_collection\service_collection $command_collection The console service collection */ - public function register_container_commands(\phpbb\di\service_collection $command_collection) + public function register_container_commands(\phpbb\di\service_collection\service_collection $command_collection) { foreach ($command_collection as $service_command) { diff --git a/phpBB/phpbb/di/service_collection.php b/phpBB/phpbb/di/service_collection/service_collection.php similarity index 97% rename from phpBB/phpbb/di/service_collection.php rename to phpBB/phpbb/di/service_collection/service_collection.php index 82ca9bf679..8085128fed 100644 --- a/phpBB/phpbb/di/service_collection.php +++ b/phpBB/phpbb/di/service_collection/service_collection.php @@ -11,7 +11,7 @@ * */ -namespace phpbb\di; +namespace phpbb\di\service_collection; use Symfony\Component\DependencyInjection\ContainerInterface; diff --git a/phpBB/phpbb/di/service_collection_iterator.php b/phpBB/phpbb/di/service_collection/service_collection_iterator.php similarity index 81% rename from phpBB/phpbb/di/service_collection_iterator.php rename to phpBB/phpbb/di/service_collection/service_collection_iterator.php index 0d031ab52d..76e22b048e 100644 --- a/phpBB/phpbb/di/service_collection_iterator.php +++ b/phpBB/phpbb/di/service_collection/service_collection_iterator.php @@ -11,7 +11,7 @@ * */ -namespace phpbb\di; +namespace phpbb\di\service_collection; /** * Iterator which loads the services when they are requested @@ -19,14 +19,14 @@ namespace phpbb\di; class service_collection_iterator extends \ArrayIterator { /** - * @var \phpbb\di\service_collection + * @var \phpbb\di\service_collection\service_collection */ protected $collection; /** * Construct an ArrayIterator for service_collection * - * @param \phpbb\di\service_collection $collection The collection to iterate over + * @param \phpbb\di\service_collection\service_collection $collection The collection to iterate over * @param int $flags Flags to control the behaviour of the ArrayObject object. * @see ArrayObject::setFlags() */ diff --git a/phpBB/phpbb/passwords/manager.php b/phpBB/phpbb/passwords/manager.php index aa9147ecf4..8974dc36d1 100644 --- a/phpBB/phpbb/passwords/manager.php +++ b/phpBB/phpbb/passwords/manager.php @@ -89,7 +89,7 @@ class manager /** * Fill algorithm type map * - * @param \phpbb\di\service_collection $hashing_algorithms + * @param \phpbb\di\service_collection\service_collection $hashing_algorithms */ protected function fill_type_map($hashing_algorithms) { diff --git a/phpBB/phpbb/profilefields/manager.php b/phpBB/phpbb/profilefields/manager.php index 4ad3214ae4..802629a10e 100644 --- a/phpBB/phpbb/profilefields/manager.php +++ b/phpBB/phpbb/profilefields/manager.php @@ -50,7 +50,7 @@ class manager /** * Service Collection object - * @var \phpbb\di\service_collection + * @var \phpbb\di\service_collection\service_collection */ protected $type_collection; @@ -76,13 +76,13 @@ class manager * @param \phpbb\event\dispatcher_interface $dispatcher Event dispatcher object * @param \phpbb\request\request $request Request object * @param \phpbb\template\template $template Template object - * @param \phpbb\di\service_collection $type_collection + * @param \phpbb\di\service_collection\service_collection $type_collection * @param \phpbb\user $user User object * @param string $fields_table * @param string $fields_language_table * @param string $fields_data_table */ - public function __construct(\phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\di\service_collection $type_collection, \phpbb\user $user, $fields_table, $fields_language_table, $fields_data_table) + public function __construct(\phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\di\service_collection\service_collection $type_collection, \phpbb\user $user, $fields_table, $fields_language_table, $fields_data_table) { $this->auth = $auth; $this->db = $db; diff --git a/tests/functions/user_delete_test.php b/tests/functions/user_delete_test.php index 21561492fd..011d251167 100644 --- a/tests/functions/user_delete_test.php +++ b/tests/functions/user_delete_test.php @@ -46,7 +46,7 @@ class phpbb_functions_user_delete_test extends phpbb_database_test_case $notification_manager = new phpbb_mock_notification_manager(); $provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config); $oauth_provider_google = new \phpbb\auth\provider\oauth\service\google($config, $request); - $oauth_provider_collection = new \phpbb\di\service_collection($phpbb_container); + $oauth_provider_collection = new \phpbb\di\service_collection\service_collection($phpbb_container); $oauth_provider_collection->offsetSet('auth.provider.oauth.service.google', $oauth_provider_google); $driver_helper = new \phpbb\passwords\driver\helper($config); diff --git a/tests/session/garbage_collection_test.php b/tests/session/garbage_collection_test.php index 3fad81c68b..5b337be44e 100644 --- a/tests/session/garbage_collection_test.php +++ b/tests/session/garbage_collection_test.php @@ -30,7 +30,7 @@ class phpbb_session_garbage_collection_test extends phpbb_session_test_case global $phpbb_container; - $plugins = new \phpbb\di\service_collection($phpbb_container); + $plugins = new \phpbb\di\service_collection\service_collection($phpbb_container); $plugins->add('core.captcha.plugins.nogd'); $phpbb_container->set( 'captcha.factory', From 9dbd8f4f9b1c8a9edd0d1734c2c61b7360d54836 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 23 Jun 2015 14:35:45 +0200 Subject: [PATCH 2/9] [ticket/13961] Add test to service_collection PHPBB3-13961 --- tests/di/service_collection_test.php | 47 ++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 tests/di/service_collection_test.php diff --git a/tests/di/service_collection_test.php b/tests/di/service_collection_test.php new file mode 100644 index 0000000000..5b51254a4a --- /dev/null +++ b/tests/di/service_collection_test.php @@ -0,0 +1,47 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +class phpbb_service_collection_test extends \phpbb_test_case +{ + /** + * @var \phpbb\di\service_collection + */ + protected $service_collection; + + public function setUp() + { + $container = new phpbb_mock_container_builder(); + $container->set('foo', new StdClass); + $container->set('bar', new StdClass); + + $this->service_collection = new \phpbb\di\service_collection($container); + $this->service_collection->add('foo'); + $this->service_collection->add('bar'); + + parent::setUp(); + } + + public function test_service_collection() + { + $service_names = array(); + + // Test the iterator + foreach ($this->service_collection as $name => $service) + { + $service_names[] = $name; + $this->assertInstanceOf('StdClass', $service); + } + + $this->assertSame(array('foo', 'bar'), $service_names); + } +} From a91c4e4f96309401f2e1a7a05ccadc876781298e Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 24 Jun 2015 13:08:19 +0200 Subject: [PATCH 3/9] [ticket/13961] Add ordered service collection PHPBB3-13961 --- phpBB/phpbb/di/pass/collection_pass.php | 11 +- .../ordered_service_collection.php | 108 ++++++++++++++++++ 2 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 phpBB/phpbb/di/service_collection/ordered_service_collection.php diff --git a/phpBB/phpbb/di/pass/collection_pass.php b/phpBB/phpbb/di/pass/collection_pass.php index a5c054674e..ccc1250c20 100644 --- a/phpBB/phpbb/di/pass/collection_pass.php +++ b/phpBB/phpbb/di/pass/collection_pass.php @@ -37,7 +37,16 @@ class collection_pass implements CompilerPassInterface foreach ($container->findTaggedServiceIds($data[0]['tag']) as $service_id => $service_data) { - $definition->addMethodCall('add', array($service_id)); + if (substr($definition->getClass(), -strlen('ordered_service_collection')) === 'ordered_service_collection') + { + $arguments = array($service_id, $service_data[0]['order']); + } + else + { + $arguments = array($service_id); + } + + $definition->addMethodCall('add', $arguments); } } } diff --git a/phpBB/phpbb/di/service_collection/ordered_service_collection.php b/phpBB/phpbb/di/service_collection/ordered_service_collection.php new file mode 100644 index 0000000000..01d0914ad4 --- /dev/null +++ b/phpBB/phpbb/di/service_collection/ordered_service_collection.php @@ -0,0 +1,108 @@ + + * @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\service_collection; + +use Symfony\Component\DependencyInjection\ContainerInterface; + +/** + * Collection of services in a specified order + */ +class ordered_service_collection extends service_collection +{ + /** + * @var bool + */ + protected $is_ordered; + + /** + * @var array + */ + protected $service_ids; + + /** + * Constructor + * + * @param ContainerInterface $container Container object + */ + public function __construct(ContainerInterface $container) + { + $this->is_ordered = false; + $this->service_ids = array(); + + parent::__construct($container); + } + + /** + * {@inheritdoc} + */ + public function offsetExists($index) + { + if (!$this->is_ordered) + { + $this->sort_services(); + } + + return parent::offsetExists($index); + } + + /** + * {@inheritdoc} + */ + public function offsetGet($index) + { + if (!$this->is_ordered) + { + $this->sort_services(); + } + + return parent::offsetGet($index); + } + + /** + * Adds a service ID to the collection + * + * @param string $service_id + * @param int $order + */ + public function add($service_id, $order) + { + if ($this->is_ordered) + { + return; + } + + $order = (int) $order; + + $this->service_ids[$order][] = $service_id; + } + + protected function sort_services() + { + if ($this->is_ordered) + { + return; + } + + ksort($this->service_ids); + foreach ($this->service_ids as $service_order_group) + { + foreach ($service_order_group as $service_id) + { + $this->offsetSet($service_id, null); + } + } + + $this->is_ordered = true; + } +} From f5b476b221d2fec5cb5886ca6174b3e7c27b1cba Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 24 Jun 2015 13:13:13 +0200 Subject: [PATCH 4/9] [ticket/13961] Add tests for ordered collections PHPBB3-13961 --- tests/di/ordered_service_collection_test.php | 51 ++++++++++++++++++++ tests/di/service_collection_test.php | 4 +- 2 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 tests/di/ordered_service_collection_test.php diff --git a/tests/di/ordered_service_collection_test.php b/tests/di/ordered_service_collection_test.php new file mode 100644 index 0000000000..046cd8ccef --- /dev/null +++ b/tests/di/ordered_service_collection_test.php @@ -0,0 +1,51 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +class phpbb_ordered_service_collection_test extends \phpbb_test_case +{ + /** + * @var \phpbb\di\service_collection\ordered_service_collection + */ + protected $service_collection; + + public function setUp() + { + $container = new phpbb_mock_container_builder(); + $container->set('foo', new StdClass); + $container->set('bar', new StdClass); + $container->set('foobar', new StdClass); + $container->set('barfoo', new StdClass); + + $this->service_collection = new \phpbb\di\service_collection\ordered_service_collection($container); + $this->service_collection->add('foo', 7); + $this->service_collection->add('bar', 3); + $this->service_collection->add('barfoo', 5); + $this->service_collection->add('foobar', 2); + + parent::setUp(); + } + + public function test_service_collection() + { + $service_names = array(); + + // Test the iterator + foreach ($this->service_collection as $name => $service) + { + $service_names[] = $name; + $this->assertInstanceOf('StdClass', $service); + } + + $this->assertSame(array('foobar', 'bar', 'barfoo', 'foo'), $service_names); + } +} diff --git a/tests/di/service_collection_test.php b/tests/di/service_collection_test.php index 5b51254a4a..e78a5180b6 100644 --- a/tests/di/service_collection_test.php +++ b/tests/di/service_collection_test.php @@ -14,7 +14,7 @@ class phpbb_service_collection_test extends \phpbb_test_case { /** - * @var \phpbb\di\service_collection + * @var \phpbb\di\service_collection\service_collection */ protected $service_collection; @@ -24,7 +24,7 @@ class phpbb_service_collection_test extends \phpbb_test_case $container->set('foo', new StdClass); $container->set('bar', new StdClass); - $this->service_collection = new \phpbb\di\service_collection($container); + $this->service_collection = new \phpbb\di\service_collection\service_collection($container); $this->service_collection->add('foo'); $this->service_collection->add('bar'); From a34a65afdce363aed65d037576278aef4484b753 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 24 Jun 2015 15:15:38 +0200 Subject: [PATCH 5/9] [ticket/13691] Add services when the iterator requested PHPBB3-13691 --- .../ordered_service_collection.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/phpBB/phpbb/di/service_collection/ordered_service_collection.php b/phpBB/phpbb/di/service_collection/ordered_service_collection.php index 01d0914ad4..f012abcd09 100644 --- a/phpBB/phpbb/di/service_collection/ordered_service_collection.php +++ b/phpBB/phpbb/di/service_collection/ordered_service_collection.php @@ -43,6 +43,19 @@ class ordered_service_collection extends service_collection parent::__construct($container); } + /** + * {@inheritdoc} + */ + public function getIterator() + { + if (!$this->is_ordered) + { + $this->sort_services(); + } + + return new service_collection_iterator($this); + } + /** * {@inheritdoc} */ From 050de400d741d48403fb32485933d1fe161e89b0 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 24 Jun 2015 15:35:47 +0200 Subject: [PATCH 6/9] [ticket/13961] Fix compatibility issue with parent class PHPBB3-13961 --- .../phpbb/di/service_collection/ordered_service_collection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/di/service_collection/ordered_service_collection.php b/phpBB/phpbb/di/service_collection/ordered_service_collection.php index f012abcd09..8d56434504 100644 --- a/phpBB/phpbb/di/service_collection/ordered_service_collection.php +++ b/phpBB/phpbb/di/service_collection/ordered_service_collection.php @@ -88,7 +88,7 @@ class ordered_service_collection extends service_collection * @param string $service_id * @param int $order */ - public function add($service_id, $order) + public function add($service_id, $order = 0) { if ($this->is_ordered) { From b09293d5ff38633d506083cffc0a9dd2c98c15c4 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 26 Jun 2015 01:02:04 +0200 Subject: [PATCH 7/9] [ticket/13961] Move back service_collections under original namespace PHPBB3-13961 --- phpBB/config/default/container/services_auth.yml | 2 +- phpBB/config/default/container/services_avatar.yml | 2 +- phpBB/config/default/container/services_captcha.yml | 2 +- phpBB/config/default/container/services_console.yml | 2 +- phpBB/config/default/container/services_cron.yml | 2 +- phpBB/config/default/container/services_migrator.yml | 2 +- .../config/default/container/services_mimetype_guesser.yml | 2 +- phpBB/config/default/container/services_notification.yml | 6 +++--- phpBB/config/default/container/services_password.yml | 2 +- phpBB/config/default/container/services_profilefield.yml | 2 +- phpBB/config/default/container/services_twig.yml | 2 +- phpBB/includes/acp/acp_profile.php | 2 +- phpBB/phpbb/auth/provider/oauth/oauth.php | 6 +++--- phpBB/phpbb/auth/provider_collection.php | 2 +- phpBB/phpbb/captcha/factory.php | 6 +++--- phpBB/phpbb/console/application.php | 4 ++-- .../{service_collection => }/ordered_service_collection.php | 2 +- .../di/{service_collection => }/service_collection.php | 2 +- .../service_collection_iterator.php | 6 +++--- phpBB/phpbb/passwords/manager.php | 2 +- phpBB/phpbb/profilefields/manager.php | 6 +++--- tests/di/ordered_service_collection_test.php | 4 ++-- tests/di/service_collection_test.php | 4 ++-- tests/functions/user_delete_test.php | 2 +- tests/session/garbage_collection_test.php | 2 +- 25 files changed, 38 insertions(+), 38 deletions(-) rename phpBB/phpbb/di/{service_collection => }/ordered_service_collection.php (98%) rename phpBB/phpbb/di/{service_collection => }/service_collection.php (97%) rename phpBB/phpbb/di/{service_collection => }/service_collection_iterator.php (81%) diff --git a/phpBB/config/default/container/services_auth.yml b/phpBB/config/default/container/services_auth.yml index 28b98a98b7..88a90ca2d6 100644 --- a/phpBB/config/default/container/services_auth.yml +++ b/phpBB/config/default/container/services_auth.yml @@ -69,7 +69,7 @@ services: # ----- OAuth services providers ----- auth.provider.oauth.service_collection: - class: phpbb\di\service_collection\service_collection + class: phpbb\di\service_collection arguments: - @service_container tags: diff --git a/phpBB/config/default/container/services_avatar.yml b/phpBB/config/default/container/services_avatar.yml index cd5b0756c6..c74bef3d66 100644 --- a/phpBB/config/default/container/services_avatar.yml +++ b/phpBB/config/default/container/services_avatar.yml @@ -7,7 +7,7 @@ services: # ----- Avatar drivers ----- avatar.driver_collection: - class: phpbb\di\service_collection\service_collection + class: phpbb\di\service_collection arguments: - @service_container tags: diff --git a/phpBB/config/default/container/services_captcha.yml b/phpBB/config/default/container/services_captcha.yml index 9e4150b094..e3f617e909 100644 --- a/phpBB/config/default/container/services_captcha.yml +++ b/phpBB/config/default/container/services_captcha.yml @@ -8,7 +8,7 @@ services: # ----- Captcha plugins ----- # Scope MUST be prototype for all the plugins to work. captcha.plugins.service_collection: - class: phpbb\di\service_collection\service_collection + class: phpbb\di\service_collection arguments: - @service_container tags: diff --git a/phpBB/config/default/container/services_console.yml b/phpBB/config/default/container/services_console.yml index 36e2bd5729..f0ae6c8ab4 100644 --- a/phpBB/config/default/container/services_console.yml +++ b/phpBB/config/default/container/services_console.yml @@ -1,6 +1,6 @@ services: console.command_collection: - class: phpbb\di\service_collection\service_collection + class: phpbb\di\service_collection arguments: - @service_container tags: diff --git a/phpBB/config/default/container/services_cron.yml b/phpBB/config/default/container/services_cron.yml index cc3c70c542..c5b88df181 100644 --- a/phpBB/config/default/container/services_cron.yml +++ b/phpBB/config/default/container/services_cron.yml @@ -15,7 +15,7 @@ services: # ----- Cron tasks ----- cron.task_collection: - class: phpbb\di\service_collection\service_collection + class: phpbb\di\service_collection arguments: - @service_container tags: diff --git a/phpBB/config/default/container/services_migrator.yml b/phpBB/config/default/container/services_migrator.yml index 8c81aec8b3..01bd7d3a11 100644 --- a/phpBB/config/default/container/services_migrator.yml +++ b/phpBB/config/default/container/services_migrator.yml @@ -19,7 +19,7 @@ services: # ----- Migrator's tools ----- migrator.tool_collection: - class: phpbb\di\service_collection\service_collection + class: phpbb\di\service_collection arguments: - @service_container tags: diff --git a/phpBB/config/default/container/services_mimetype_guesser.yml b/phpBB/config/default/container/services_mimetype_guesser.yml index f22a41613a..2e89ed3c1f 100644 --- a/phpBB/config/default/container/services_mimetype_guesser.yml +++ b/phpBB/config/default/container/services_mimetype_guesser.yml @@ -1,6 +1,6 @@ services: mimetype.guesser_collection: - class: phpbb\di\service_collection\service_collection + class: phpbb\di\service_collection arguments: - @service_container tags: diff --git a/phpBB/config/default/container/services_notification.yml b/phpBB/config/default/container/services_notification.yml index 896b93f75b..c3bbcddfa6 100644 --- a/phpBB/config/default/container/services_notification.yml +++ b/phpBB/config/default/container/services_notification.yml @@ -20,7 +20,7 @@ services: # ----- Notification's types ----- # Scope MUST be prototype for all the plugins to work. notification.type_collection: - class: phpbb\di\service_collection\service_collection + class: phpbb\di\service_collection arguments: - @service_container tags: @@ -351,11 +351,11 @@ services: - %tables.user_notifications% tags: - { name: notification.type } - + # ----- Notification's methods ----- # Scope MUST be prototype for all the plugins to work. notification.method_collection: - class: phpbb\di\service_collection\service_collection + class: phpbb\di\service_collection arguments: - @service_container tags: diff --git a/phpBB/config/default/container/services_password.yml b/phpBB/config/default/container/services_password.yml index 22530f33d6..cb45ec3d42 100644 --- a/phpBB/config/default/container/services_password.yml +++ b/phpBB/config/default/container/services_password.yml @@ -18,7 +18,7 @@ services: # ----- Password's drivers ----- passwords.driver_collection: - class: phpbb\di\service_collection\service_collection + class: phpbb\di\service_collection arguments: - @service_container tags: diff --git a/phpBB/config/default/container/services_profilefield.yml b/phpBB/config/default/container/services_profilefield.yml index 9bbc0be4c9..5ccfef9148 100644 --- a/phpBB/config/default/container/services_profilefield.yml +++ b/phpBB/config/default/container/services_profilefield.yml @@ -21,7 +21,7 @@ services: # ----- Profile fields types ----- profilefields.type_collection: - class: phpbb\di\service_collection\service_collection + class: phpbb\di\service_collection arguments: - @service_container tags: diff --git a/phpBB/config/default/container/services_twig.yml b/phpBB/config/default/container/services_twig.yml index 2c5b5a8398..2799892376 100644 --- a/phpBB/config/default/container/services_twig.yml +++ b/phpBB/config/default/container/services_twig.yml @@ -25,7 +25,7 @@ services: - @filesystem template.twig.extensions.collection: - class: phpbb\di\service_collection\service_collection + class: phpbb\di\service_collection arguments: - @service_container tags: diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index 79feda88f1..146e116cfd 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -27,7 +27,7 @@ class acp_profile var $lang_defs; /** - * @var \phpbb\di\service_collection\service_collection + * @var \phpbb\di\service_collection */ protected $type_collection; diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 612446a2a8..be0fbf5831 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -72,7 +72,7 @@ class oauth extends \phpbb\auth\provider\base /** * All OAuth service providers * - * @var \phpbb\di\service_collection\service_collection Contains \phpbb\auth\provider\oauth\service_interface + * @var \phpbb\di\service_collection Contains \phpbb\auth\provider\oauth\service_interface */ protected $service_providers; @@ -121,13 +121,13 @@ class oauth extends \phpbb\auth\provider\base * @param \phpbb\user $user * @param string $auth_provider_oauth_token_storage_table * @param string $auth_provider_oauth_token_account_assoc - * @param \phpbb\di\service_collection\service_collection $service_providers Contains \phpbb\auth\provider\oauth\service_interface + * @param \phpbb\di\service_collection $service_providers Contains \phpbb\auth\provider\oauth\service_interface * @param string $users_table * @param \Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container DI container * @param string $phpbb_root_path * @param string $php_ext */ - public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\passwords\manager $passwords_manager, \phpbb\request\request_interface $request, \phpbb\user $user, $auth_provider_oauth_token_storage_table, $auth_provider_oauth_token_account_assoc, \phpbb\di\service_collection\service_collection $service_providers, $users_table, \Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container, $phpbb_root_path, $php_ext) + public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\passwords\manager $passwords_manager, \phpbb\request\request_interface $request, \phpbb\user $user, $auth_provider_oauth_token_storage_table, $auth_provider_oauth_token_account_assoc, \phpbb\di\service_collection $service_providers, $users_table, \Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container, $phpbb_root_path, $php_ext) { $this->db = $db; $this->config = $config; diff --git a/phpBB/phpbb/auth/provider_collection.php b/phpBB/phpbb/auth/provider_collection.php index 71da30e4c4..8e7e9e2cc1 100644 --- a/phpBB/phpbb/auth/provider_collection.php +++ b/phpBB/phpbb/auth/provider_collection.php @@ -18,7 +18,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; /** * Collection of auth providers to be configured at container compile time. */ -class provider_collection extends \phpbb\di\service_collection\service_collection +class provider_collection extends \phpbb\di\service_collection { /** @var \phpbb\config\config phpBB Config */ protected $config; diff --git a/phpBB/phpbb/captcha/factory.php b/phpBB/phpbb/captcha/factory.php index 1357e919bb..dd44aca8bb 100644 --- a/phpBB/phpbb/captcha/factory.php +++ b/phpBB/phpbb/captcha/factory.php @@ -21,7 +21,7 @@ class factory private $container; /** - * @var \phpbb\di\service_collection\service_collection + * @var \phpbb\di\service_collection */ private $plugins; @@ -29,9 +29,9 @@ class factory * Constructor * * @param \Symfony\Component\DependencyInjection\ContainerInterface $container - * @param \phpbb\di\service_collection\service_collection $plugins + * @param \phpbb\di\service_collection $plugins */ - public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container, \phpbb\di\service_collection\service_collection $plugins) + public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container, \phpbb\di\service_collection $plugins) { $this->container = $container; $this->plugins = $plugins; diff --git a/phpBB/phpbb/console/application.php b/phpBB/phpbb/console/application.php index fa847cd64d..bc4897af18 100644 --- a/phpBB/phpbb/console/application.php +++ b/phpBB/phpbb/console/application.php @@ -89,9 +89,9 @@ class application extends \Symfony\Component\Console\Application /** * Register a set of commands from the container * - * @param \phpbb\di\service_collection\service_collection $command_collection The console service collection + * @param \phpbb\di\service_collection $command_collection The console service collection */ - public function register_container_commands(\phpbb\di\service_collection\service_collection $command_collection) + public function register_container_commands(\phpbb\di\service_collection $command_collection) { foreach ($command_collection as $service_command) { diff --git a/phpBB/phpbb/di/service_collection/ordered_service_collection.php b/phpBB/phpbb/di/ordered_service_collection.php similarity index 98% rename from phpBB/phpbb/di/service_collection/ordered_service_collection.php rename to phpBB/phpbb/di/ordered_service_collection.php index 8d56434504..46f397a004 100644 --- a/phpBB/phpbb/di/service_collection/ordered_service_collection.php +++ b/phpBB/phpbb/di/ordered_service_collection.php @@ -11,7 +11,7 @@ * */ -namespace phpbb\di\service_collection; +namespace phpbb\di; use Symfony\Component\DependencyInjection\ContainerInterface; diff --git a/phpBB/phpbb/di/service_collection/service_collection.php b/phpBB/phpbb/di/service_collection.php similarity index 97% rename from phpBB/phpbb/di/service_collection/service_collection.php rename to phpBB/phpbb/di/service_collection.php index 8085128fed..82ca9bf679 100644 --- a/phpBB/phpbb/di/service_collection/service_collection.php +++ b/phpBB/phpbb/di/service_collection.php @@ -11,7 +11,7 @@ * */ -namespace phpbb\di\service_collection; +namespace phpbb\di; use Symfony\Component\DependencyInjection\ContainerInterface; diff --git a/phpBB/phpbb/di/service_collection/service_collection_iterator.php b/phpBB/phpbb/di/service_collection_iterator.php similarity index 81% rename from phpBB/phpbb/di/service_collection/service_collection_iterator.php rename to phpBB/phpbb/di/service_collection_iterator.php index 76e22b048e..0d031ab52d 100644 --- a/phpBB/phpbb/di/service_collection/service_collection_iterator.php +++ b/phpBB/phpbb/di/service_collection_iterator.php @@ -11,7 +11,7 @@ * */ -namespace phpbb\di\service_collection; +namespace phpbb\di; /** * Iterator which loads the services when they are requested @@ -19,14 +19,14 @@ namespace phpbb\di\service_collection; class service_collection_iterator extends \ArrayIterator { /** - * @var \phpbb\di\service_collection\service_collection + * @var \phpbb\di\service_collection */ protected $collection; /** * Construct an ArrayIterator for service_collection * - * @param \phpbb\di\service_collection\service_collection $collection The collection to iterate over + * @param \phpbb\di\service_collection $collection The collection to iterate over * @param int $flags Flags to control the behaviour of the ArrayObject object. * @see ArrayObject::setFlags() */ diff --git a/phpBB/phpbb/passwords/manager.php b/phpBB/phpbb/passwords/manager.php index 8974dc36d1..aa9147ecf4 100644 --- a/phpBB/phpbb/passwords/manager.php +++ b/phpBB/phpbb/passwords/manager.php @@ -89,7 +89,7 @@ class manager /** * Fill algorithm type map * - * @param \phpbb\di\service_collection\service_collection $hashing_algorithms + * @param \phpbb\di\service_collection $hashing_algorithms */ protected function fill_type_map($hashing_algorithms) { diff --git a/phpBB/phpbb/profilefields/manager.php b/phpBB/phpbb/profilefields/manager.php index 802629a10e..4ad3214ae4 100644 --- a/phpBB/phpbb/profilefields/manager.php +++ b/phpBB/phpbb/profilefields/manager.php @@ -50,7 +50,7 @@ class manager /** * Service Collection object - * @var \phpbb\di\service_collection\service_collection + * @var \phpbb\di\service_collection */ protected $type_collection; @@ -76,13 +76,13 @@ class manager * @param \phpbb\event\dispatcher_interface $dispatcher Event dispatcher object * @param \phpbb\request\request $request Request object * @param \phpbb\template\template $template Template object - * @param \phpbb\di\service_collection\service_collection $type_collection + * @param \phpbb\di\service_collection $type_collection * @param \phpbb\user $user User object * @param string $fields_table * @param string $fields_language_table * @param string $fields_data_table */ - public function __construct(\phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\di\service_collection\service_collection $type_collection, \phpbb\user $user, $fields_table, $fields_language_table, $fields_data_table) + public function __construct(\phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\di\service_collection $type_collection, \phpbb\user $user, $fields_table, $fields_language_table, $fields_data_table) { $this->auth = $auth; $this->db = $db; diff --git a/tests/di/ordered_service_collection_test.php b/tests/di/ordered_service_collection_test.php index 046cd8ccef..47e6d23744 100644 --- a/tests/di/ordered_service_collection_test.php +++ b/tests/di/ordered_service_collection_test.php @@ -14,7 +14,7 @@ class phpbb_ordered_service_collection_test extends \phpbb_test_case { /** - * @var \phpbb\di\service_collection\ordered_service_collection + * @var \phpbb\di\ordered_service_collection */ protected $service_collection; @@ -26,7 +26,7 @@ class phpbb_ordered_service_collection_test extends \phpbb_test_case $container->set('foobar', new StdClass); $container->set('barfoo', new StdClass); - $this->service_collection = new \phpbb\di\service_collection\ordered_service_collection($container); + $this->service_collection = new \phpbb\di\ordered_service_collection($container); $this->service_collection->add('foo', 7); $this->service_collection->add('bar', 3); $this->service_collection->add('barfoo', 5); diff --git a/tests/di/service_collection_test.php b/tests/di/service_collection_test.php index e78a5180b6..5b51254a4a 100644 --- a/tests/di/service_collection_test.php +++ b/tests/di/service_collection_test.php @@ -14,7 +14,7 @@ class phpbb_service_collection_test extends \phpbb_test_case { /** - * @var \phpbb\di\service_collection\service_collection + * @var \phpbb\di\service_collection */ protected $service_collection; @@ -24,7 +24,7 @@ class phpbb_service_collection_test extends \phpbb_test_case $container->set('foo', new StdClass); $container->set('bar', new StdClass); - $this->service_collection = new \phpbb\di\service_collection\service_collection($container); + $this->service_collection = new \phpbb\di\service_collection($container); $this->service_collection->add('foo'); $this->service_collection->add('bar'); diff --git a/tests/functions/user_delete_test.php b/tests/functions/user_delete_test.php index 011d251167..21561492fd 100644 --- a/tests/functions/user_delete_test.php +++ b/tests/functions/user_delete_test.php @@ -46,7 +46,7 @@ class phpbb_functions_user_delete_test extends phpbb_database_test_case $notification_manager = new phpbb_mock_notification_manager(); $provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config); $oauth_provider_google = new \phpbb\auth\provider\oauth\service\google($config, $request); - $oauth_provider_collection = new \phpbb\di\service_collection\service_collection($phpbb_container); + $oauth_provider_collection = new \phpbb\di\service_collection($phpbb_container); $oauth_provider_collection->offsetSet('auth.provider.oauth.service.google', $oauth_provider_google); $driver_helper = new \phpbb\passwords\driver\helper($config); diff --git a/tests/session/garbage_collection_test.php b/tests/session/garbage_collection_test.php index 5b337be44e..3fad81c68b 100644 --- a/tests/session/garbage_collection_test.php +++ b/tests/session/garbage_collection_test.php @@ -30,7 +30,7 @@ class phpbb_session_garbage_collection_test extends phpbb_session_test_case global $phpbb_container; - $plugins = new \phpbb\di\service_collection\service_collection($phpbb_container); + $plugins = new \phpbb\di\service_collection($phpbb_container); $plugins->add('core.captcha.plugins.nogd'); $phpbb_container->set( 'captcha.factory', From c80cf87b90eefab664ecf69f29796f9390a3ff17 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sat, 27 Jun 2015 12:49:10 +0200 Subject: [PATCH 8/9] [ticket/13961] Allow the collection to be modified runtime PHPBB3-13961 --- phpBB/phpbb/di/ordered_service_collection.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/phpBB/phpbb/di/ordered_service_collection.php b/phpBB/phpbb/di/ordered_service_collection.php index 46f397a004..046012ae5b 100644 --- a/phpBB/phpbb/di/ordered_service_collection.php +++ b/phpBB/phpbb/di/ordered_service_collection.php @@ -90,14 +90,9 @@ class ordered_service_collection extends service_collection */ public function add($service_id, $order = 0) { - if ($this->is_ordered) - { - return; - } - $order = (int) $order; - $this->service_ids[$order][] = $service_id; + $this->is_ordered = false; } protected function sort_services() @@ -107,6 +102,7 @@ class ordered_service_collection extends service_collection return; } + $this->exchangeArray(array()); ksort($this->service_ids); foreach ($this->service_ids as $service_order_group) { From 108b9833a10ff657d5d55ba1f976ad7314ecbfa3 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 2 Jul 2015 16:10:55 +0200 Subject: [PATCH 9/9] [ticket/13961] Define behaviour when the array is modified in a loop PHPBB3-13961 --- phpBB/phpbb/di/service_collection_iterator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/di/service_collection_iterator.php b/phpBB/phpbb/di/service_collection_iterator.php index 0d031ab52d..31bc156e99 100644 --- a/phpBB/phpbb/di/service_collection_iterator.php +++ b/phpBB/phpbb/di/service_collection_iterator.php @@ -32,7 +32,7 @@ class service_collection_iterator extends \ArrayIterator */ public function __construct(service_collection $collection, $flags = 0) { - parent::__construct($collection, $flags); + parent::__construct($collection->getArrayCopy(), $flags); $this->collection = $collection; }