From c22562f5cdb3db9482a7c6bc2398ebb12cbcfb8b Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 30 May 2014 14:57:19 +0200 Subject: [PATCH 01/37] [ticket/12620] Allow the user to define multiples environments PHPBB3-12620 --- phpBB/common.php | 5 ++++ phpBB/config/config_debug.yml | 2 ++ phpBB/config/config_productive.yml | 2 ++ phpBB/config/services.yml | 30 +++++++++---------- phpBB/config/{auth.yml => services_auth.yml} | 0 .../{avatar.yml => services_avatar.yml} | 0 .../{captcha.yml => services_captcha.yml} | 0 .../{console.yml => services_console.yml} | 0 .../{content.yml => services_content.yml} | 0 phpBB/config/{cron.yml => services_cron.yml} | 0 phpBB/config/{db.yml => services_db.yml} | 0 .../config/{event.yml => services_event.yml} | 0 phpBB/config/{feed.yml => services_feed.yml} | 0 ...sser.yml => services_mimetype_guesser.yml} | 0 ...fication.yml => services_notification.yml} | 0 .../{password.yml => services_password.yml} | 0 ...ilefield.yml => services_profilefield.yml} | 0 phpBB/config/{twig.yml => services_twig.yml} | 0 phpBB/config/{user.yml => services_user.yml} | 0 phpBB/includes/functions_install.php | 4 +-- phpBB/phpbb/di/extension/core.php | 2 +- 21 files changed, 27 insertions(+), 18 deletions(-) create mode 100644 phpBB/config/config_debug.yml create mode 100644 phpBB/config/config_productive.yml rename phpBB/config/{auth.yml => services_auth.yml} (100%) rename phpBB/config/{avatar.yml => services_avatar.yml} (100%) rename phpBB/config/{captcha.yml => services_captcha.yml} (100%) rename phpBB/config/{console.yml => services_console.yml} (100%) rename phpBB/config/{content.yml => services_content.yml} (100%) rename phpBB/config/{cron.yml => services_cron.yml} (100%) rename phpBB/config/{db.yml => services_db.yml} (100%) rename phpBB/config/{event.yml => services_event.yml} (100%) rename phpBB/config/{feed.yml => services_feed.yml} (100%) rename phpBB/config/{mimetype_guesser.yml => services_mimetype_guesser.yml} (100%) rename phpBB/config/{notification.yml => services_notification.yml} (100%) rename phpBB/config/{password.yml => services_password.yml} (100%) rename phpBB/config/{profilefield.yml => services_profilefield.yml} (100%) rename phpBB/config/{twig.yml => services_twig.yml} (100%) rename phpBB/config/{user.yml => services_user.yml} (100%) diff --git a/phpBB/common.php b/phpBB/common.php index 0782bd7321..d4549dc2d4 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -29,6 +29,11 @@ $phpbb_class_loader->register(); $phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx); extract($phpbb_config_php_file->get_all()); +if (!defined('ENVIRONMENT')) +{ + @define('ENVIRONMENT', 'productive'); +} + if (!defined('PHPBB_INSTALLED')) { // Redirect the user to the installer diff --git a/phpBB/config/config_debug.yml b/phpBB/config/config_debug.yml new file mode 100644 index 0000000000..6982aa4f83 --- /dev/null +++ b/phpBB/config/config_debug.yml @@ -0,0 +1,2 @@ +imports: + - { resource: services.yml } diff --git a/phpBB/config/config_productive.yml b/phpBB/config/config_productive.yml new file mode 100644 index 0000000000..6982aa4f83 --- /dev/null +++ b/phpBB/config/config_productive.yml @@ -0,0 +1,2 @@ +imports: + - { resource: services.yml } diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index f6dbae4a76..3f36a5178a 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -1,19 +1,19 @@ imports: - - { resource: auth.yml } - - { resource: avatar.yml } - - { resource: captcha.yml } - - { resource: console.yml } - - { resource: content.yml } - - { resource: cron.yml } - - { resource: db.yml } - - { resource: event.yml } - - { resource: feed.yml } - - { resource: mimetype_guesser.yml } - - { resource: notification.yml } - - { resource: password.yml } - - { resource: profilefield.yml } - - { resource: twig.yml } - - { resource: user.yml } + - { resource: services_auth.yml } + - { resource: services_avatar.yml } + - { resource: services_captcha.yml } + - { resource: services_console.yml } + - { resource: services_content.yml } + - { resource: services_cron.yml } + - { resource: services_db.yml } + - { resource: services_event.yml } + - { resource: services_feed.yml } + - { resource: services_mimetype_guesser.yml } + - { resource: services_notification.yml } + - { resource: services_password.yml } + - { resource: services_profilefield.yml } + - { resource: services_twig.yml } + - { resource: services_user.yml } - { resource: tables.yml } - { resource: parameters.yml } diff --git a/phpBB/config/auth.yml b/phpBB/config/services_auth.yml similarity index 100% rename from phpBB/config/auth.yml rename to phpBB/config/services_auth.yml diff --git a/phpBB/config/avatar.yml b/phpBB/config/services_avatar.yml similarity index 100% rename from phpBB/config/avatar.yml rename to phpBB/config/services_avatar.yml diff --git a/phpBB/config/captcha.yml b/phpBB/config/services_captcha.yml similarity index 100% rename from phpBB/config/captcha.yml rename to phpBB/config/services_captcha.yml diff --git a/phpBB/config/console.yml b/phpBB/config/services_console.yml similarity index 100% rename from phpBB/config/console.yml rename to phpBB/config/services_console.yml diff --git a/phpBB/config/content.yml b/phpBB/config/services_content.yml similarity index 100% rename from phpBB/config/content.yml rename to phpBB/config/services_content.yml diff --git a/phpBB/config/cron.yml b/phpBB/config/services_cron.yml similarity index 100% rename from phpBB/config/cron.yml rename to phpBB/config/services_cron.yml diff --git a/phpBB/config/db.yml b/phpBB/config/services_db.yml similarity index 100% rename from phpBB/config/db.yml rename to phpBB/config/services_db.yml diff --git a/phpBB/config/event.yml b/phpBB/config/services_event.yml similarity index 100% rename from phpBB/config/event.yml rename to phpBB/config/services_event.yml diff --git a/phpBB/config/feed.yml b/phpBB/config/services_feed.yml similarity index 100% rename from phpBB/config/feed.yml rename to phpBB/config/services_feed.yml diff --git a/phpBB/config/mimetype_guesser.yml b/phpBB/config/services_mimetype_guesser.yml similarity index 100% rename from phpBB/config/mimetype_guesser.yml rename to phpBB/config/services_mimetype_guesser.yml diff --git a/phpBB/config/notification.yml b/phpBB/config/services_notification.yml similarity index 100% rename from phpBB/config/notification.yml rename to phpBB/config/services_notification.yml diff --git a/phpBB/config/password.yml b/phpBB/config/services_password.yml similarity index 100% rename from phpBB/config/password.yml rename to phpBB/config/services_password.yml diff --git a/phpBB/config/profilefield.yml b/phpBB/config/services_profilefield.yml similarity index 100% rename from phpBB/config/profilefield.yml rename to phpBB/config/services_profilefield.yml diff --git a/phpBB/config/twig.yml b/phpBB/config/services_twig.yml similarity index 100% rename from phpBB/config/twig.yml rename to phpBB/config/services_twig.yml diff --git a/phpBB/config/user.yml b/phpBB/config/services_user.yml similarity index 100% rename from phpBB/config/user.yml rename to phpBB/config/services_user.yml diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 28cc603bdb..2be8e6e860 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -453,11 +453,11 @@ function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_cont if ($debug) { - $config_data .= "@define('DEBUG', true);\n"; + $config_data .= "@define('ENVIRONMENT', 'debug');\n"; } else { - $config_data .= "// @define('DEBUG', true);\n"; + $config_data .= "@define('ENVIRONMENT', 'productive');\n"; } if ($debug_container) diff --git a/phpBB/phpbb/di/extension/core.php b/phpBB/phpbb/di/extension/core.php index ca4fa5c082..d203cc7049 100644 --- a/phpBB/phpbb/di/extension/core.php +++ b/phpBB/phpbb/di/extension/core.php @@ -50,7 +50,7 @@ class core extends Extension public function load(array $config, ContainerBuilder $container) { $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->config_path))); - $loader->load('services.yml'); + $loader->load('config_' . ENVIRONMENT . '.yml'); } /** From 1a6e1ecf6f96acb7eb3fc0cc6233773ecb5125a8 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 30 May 2014 15:18:11 +0200 Subject: [PATCH 02/37] [ticket/12620] Fix tests PHPBB3-12620 --- tests/di/create_container_test.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index 4ae6017989..c98d3ff6bc 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -13,6 +13,8 @@ namespace { + define('ENVIRONMENT', 'productive'); + require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_di_container_test extends \phpbb_test_case From 873260589eaa7ac2d7e520ebe321cb8bb2609ce0 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 30 May 2014 15:29:09 +0200 Subject: [PATCH 03/37] [ticket/12620] Display error message when the environment isn't available PHPBB3-12620 --- phpBB/common.php | 23 +++++++++++++++++-- ...config_debug.yml => environment_debug.yml} | 0 ...ductive.yml => environment_productive.yml} | 0 phpBB/phpbb/di/extension/core.php | 2 +- 4 files changed, 22 insertions(+), 3 deletions(-) rename phpBB/config/{config_debug.yml => environment_debug.yml} (100%) rename phpBB/config/{config_productive.yml => environment_productive.yml} (100%) diff --git a/phpBB/common.php b/phpBB/common.php index d4549dc2d4..586c2f080f 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -96,11 +96,30 @@ set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handle $phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx); $phpbb_class_loader_ext->register(); +if (ENVIRONMENT == 'debug' && !class_exists('Goutte\Client', true)) +{ + trigger_error( + 'Composer dependencies have not been set up for the development environment yet, run ' . + "'php ../composer.phar install --dev' from the phpBB directory to do so.", + E_USER_ERROR + ); +} phpbb_load_extensions_autoloaders($phpbb_root_path); // Set up container -$phpbb_container_builder = new \phpbb\di\container_builder($phpbb_config_php_file, $phpbb_root_path, $phpEx); -$phpbb_container = $phpbb_container_builder->get_container(); +$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx); +try +{ + $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_config_php_file, $phpbb_root_path, $phpEx); + $phpbb_container = $phpbb_container_builder->get_container(); +} +catch (InvalidArgumentException $e) +{ + trigger_error( + 'The requested environment ' . ENVIRONMENT . ' is not available.', + E_USER_ERROR + ); +} $phpbb_class_loader->set_cache($phpbb_container->get('cache.driver')); $phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); diff --git a/phpBB/config/config_debug.yml b/phpBB/config/environment_debug.yml similarity index 100% rename from phpBB/config/config_debug.yml rename to phpBB/config/environment_debug.yml diff --git a/phpBB/config/config_productive.yml b/phpBB/config/environment_productive.yml similarity index 100% rename from phpBB/config/config_productive.yml rename to phpBB/config/environment_productive.yml diff --git a/phpBB/phpbb/di/extension/core.php b/phpBB/phpbb/di/extension/core.php index d203cc7049..5fb8d9ad34 100644 --- a/phpBB/phpbb/di/extension/core.php +++ b/phpBB/phpbb/di/extension/core.php @@ -50,7 +50,7 @@ class core extends Extension public function load(array $config, ContainerBuilder $container) { $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->config_path))); - $loader->load('config_' . ENVIRONMENT . '.yml'); + $loader->load('environment_' . ENVIRONMENT . '.yml'); } /** From 70201ee8fa084da667b0b1a308d48d2f3c8a541b Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 30 May 2014 15:37:45 +0200 Subject: [PATCH 04/37] [ticket/12620] Rename debug to development PHPBB3-12620 --- .../{environment_debug.yml => environment_development.yml} | 0 phpBB/includes/functions_install.php | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename phpBB/config/{environment_debug.yml => environment_development.yml} (100%) diff --git a/phpBB/config/environment_debug.yml b/phpBB/config/environment_development.yml similarity index 100% rename from phpBB/config/environment_debug.yml rename to phpBB/config/environment_development.yml diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 2be8e6e860..1b63414cec 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -453,7 +453,7 @@ function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_cont if ($debug) { - $config_data .= "@define('ENVIRONMENT', 'debug');\n"; + $config_data .= "@define('ENVIRONMENT', 'development');\n"; } else { From 733ae584dd09a0d922fa8f56a0bdc7b3ae359266 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 30 May 2014 15:41:54 +0200 Subject: [PATCH 05/37] [ticket/12620] Improve error message PHPBB3-12620 --- phpBB/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/common.php b/phpBB/common.php index 586c2f080f..47c9085d5f 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -99,7 +99,7 @@ $phpbb_class_loader_ext->register(); if (ENVIRONMENT == 'debug' && !class_exists('Goutte\Client', true)) { trigger_error( - 'Composer dependencies have not been set up for the development environment yet, run ' . + 'Composer development dependencies have not been set up for the development environment yet, run ' . "'php ../composer.phar install --dev' from the phpBB directory to do so.", E_USER_ERROR ); From c4842fe119a2947c3d6c34239f83d4d887a39f00 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 30 May 2014 16:18:11 +0200 Subject: [PATCH 06/37] [ticket/12620] Fix functional tests PHPBB3-12620 --- phpBB/includes/functions_install.php | 1 + phpBB/install/index.php | 1 + 2 files changed, 2 insertions(+) diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 1b63414cec..4ed44da0b1 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -472,6 +472,7 @@ function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_cont if ($debug_test) { $config_data .= "@define('DEBUG_TEST', true);\n"; + $config_data .= "@define('DEBUG', true);\n"; // Mandatory for the functional tests, will be removed by PHPBB3-12623 } return $config_data; diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 3dd73adc60..00a35b4690 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -16,6 +16,7 @@ */ define('IN_PHPBB', true); define('IN_INSTALL', true); +define('ENVIRONMENT', 'productive'); /**#@-*/ $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../'; From 7fa3b4c6860d85c7616e2182241eefe9515dc8a8 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 30 May 2014 18:33:56 +0200 Subject: [PATCH 07/37] [ticket/12620] Rename productive to production PHPBB3-12620 --- phpBB/common.php | 2 +- .../{environment_productive.yml => environment_production.yml} | 0 phpBB/includes/functions_install.php | 2 +- phpBB/install/index.php | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename phpBB/config/{environment_productive.yml => environment_production.yml} (100%) diff --git a/phpBB/common.php b/phpBB/common.php index 47c9085d5f..a1142e4af4 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -31,7 +31,7 @@ extract($phpbb_config_php_file->get_all()); if (!defined('ENVIRONMENT')) { - @define('ENVIRONMENT', 'productive'); + @define('ENVIRONMENT', 'production'); } if (!defined('PHPBB_INSTALLED')) diff --git a/phpBB/config/environment_productive.yml b/phpBB/config/environment_production.yml similarity index 100% rename from phpBB/config/environment_productive.yml rename to phpBB/config/environment_production.yml diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 4ed44da0b1..e0ecda3bfa 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -457,7 +457,7 @@ function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_cont } else { - $config_data .= "@define('ENVIRONMENT', 'productive');\n"; + $config_data .= "@define('ENVIRONMENT', 'production');\n"; } if ($debug_container) diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 00a35b4690..8edc447492 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -16,7 +16,7 @@ */ define('IN_PHPBB', true); define('IN_INSTALL', true); -define('ENVIRONMENT', 'productive'); +define('ENVIRONMENT', 'production'); /**#@-*/ $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../'; From 943e27dffa1ecea1c34e9ae5b11c49186f30e046 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 30 May 2014 22:55:27 +0200 Subject: [PATCH 08/37] [ticket/12620] Fix functional tests PHPBB3-12620 --- tests/di/create_container_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index c98d3ff6bc..2ddbf68f39 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -13,7 +13,7 @@ namespace { - define('ENVIRONMENT', 'productive'); + define('ENVIRONMENT', 'production'); require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; From 8664d3229a511eb320fef3df6a852d1a20852dae Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 20 Jun 2014 18:49:19 +0200 Subject: [PATCH 09/37] [ticket/12620] Split the environments into differents folders PHPBB3-12620 --- phpBB/config/{ => default}/services.yml | 0 phpBB/config/{ => default}/services_auth.yml | 0 .../default/services_auth_providers.yml | 86 ++++ .../config/{ => default}/services_avatar.yml | 0 phpBB/config/default/services_avatars.yml | 60 +++ .../config/{ => default}/services_captcha.yml | 0 .../config/{ => default}/services_console.yml | 0 .../config/{ => default}/services_content.yml | 0 phpBB/config/{ => default}/services_cron.yml | 0 phpBB/config/default/services_cron_tasks.yml | 125 ++++++ phpBB/config/{ => default}/services_db.yml | 0 phpBB/config/{ => default}/services_event.yml | 0 phpBB/config/{ => default}/services_feed.yml | 0 phpBB/config/default/services_migrator.yml | 60 +++ .../services_mimetype_guesser.yml | 0 .../default/services_mimetype_guessers.yml | 43 ++ .../{ => default}/services_notification.yml | 0 .../config/default/services_notifications.yml | 368 ++++++++++++++++++ .../{ => default}/services_password.yml | 0 phpBB/config/default/services_passwords.yml | 128 ++++++ .../{ => default}/services_profilefield.yml | 0 .../config/default/services_profilefields.yml | 101 +++++ phpBB/config/{ => default}/services_twig.yml | 0 phpBB/config/{ => default}/services_user.yml | 0 phpBB/config/{ => default}/tables.yml | 0 phpBB/config/development/environment.yml | 2 + phpBB/config/environment_development.yml | 2 - phpBB/config/environment_production.yml | 2 - phpBB/config/production/environment.yml | 2 + phpBB/phpbb/di/extension/core.php | 2 +- 30 files changed, 976 insertions(+), 5 deletions(-) rename phpBB/config/{ => default}/services.yml (100%) rename phpBB/config/{ => default}/services_auth.yml (100%) create mode 100644 phpBB/config/default/services_auth_providers.yml rename phpBB/config/{ => default}/services_avatar.yml (100%) create mode 100644 phpBB/config/default/services_avatars.yml rename phpBB/config/{ => default}/services_captcha.yml (100%) rename phpBB/config/{ => default}/services_console.yml (100%) rename phpBB/config/{ => default}/services_content.yml (100%) rename phpBB/config/{ => default}/services_cron.yml (100%) create mode 100644 phpBB/config/default/services_cron_tasks.yml rename phpBB/config/{ => default}/services_db.yml (100%) rename phpBB/config/{ => default}/services_event.yml (100%) rename phpBB/config/{ => default}/services_feed.yml (100%) create mode 100644 phpBB/config/default/services_migrator.yml rename phpBB/config/{ => default}/services_mimetype_guesser.yml (100%) create mode 100644 phpBB/config/default/services_mimetype_guessers.yml rename phpBB/config/{ => default}/services_notification.yml (100%) create mode 100644 phpBB/config/default/services_notifications.yml rename phpBB/config/{ => default}/services_password.yml (100%) create mode 100644 phpBB/config/default/services_passwords.yml rename phpBB/config/{ => default}/services_profilefield.yml (100%) create mode 100644 phpBB/config/default/services_profilefields.yml rename phpBB/config/{ => default}/services_twig.yml (100%) rename phpBB/config/{ => default}/services_user.yml (100%) rename phpBB/config/{ => default}/tables.yml (100%) create mode 100644 phpBB/config/development/environment.yml delete mode 100644 phpBB/config/environment_development.yml delete mode 100644 phpBB/config/environment_production.yml create mode 100644 phpBB/config/production/environment.yml diff --git a/phpBB/config/services.yml b/phpBB/config/default/services.yml similarity index 100% rename from phpBB/config/services.yml rename to phpBB/config/default/services.yml diff --git a/phpBB/config/services_auth.yml b/phpBB/config/default/services_auth.yml similarity index 100% rename from phpBB/config/services_auth.yml rename to phpBB/config/default/services_auth.yml diff --git a/phpBB/config/default/services_auth_providers.yml b/phpBB/config/default/services_auth_providers.yml new file mode 100644 index 0000000000..89303a684a --- /dev/null +++ b/phpBB/config/default/services_auth_providers.yml @@ -0,0 +1,86 @@ +services: + auth.provider_collection: + class: phpbb\auth\provider_collection + arguments: + - @service_container + - @config + tags: + - { name: service_collection, tag: auth.provider } + auth.provider.db: + class: phpbb\auth\provider\db + arguments: + - @dbal.conn + - @config + - @passwords.manager + - @request + - @user + - @service_container + - %core.root_path% + - %core.php_ext% + tags: + - { name: auth.provider } + auth.provider.apache: + class: phpbb\auth\provider\apache + arguments: + - @dbal.conn + - @config + - @passwords.manager + - @request + - @user + - %core.root_path% + - %core.php_ext% + tags: + - { name: auth.provider } + auth.provider.ldap: + class: phpbb\auth\provider\ldap + arguments: + - @dbal.conn + - @config + - @passwords.manager + - @user + tags: + - { name: auth.provider } + auth.provider.oauth: + class: phpbb\auth\provider\oauth\oauth + arguments: + - @dbal.conn + - @config + - @passwords.manager + - @request + - @user + - %tables.auth_provider_oauth_token_storage% + - %tables.auth_provider_oauth_account_assoc% + - @auth.provider.oauth.service_collection + - %tables.users% + - @service_container + - %core.root_path% + - %core.php_ext% + tags: + - { name: auth.provider } + auth.provider.oauth.service_collection: + class: phpbb\di\service_collection + arguments: + - @service_container + tags: + - { name: service_collection, tag: auth.provider.oauth.service } + auth.provider.oauth.service.bitly: + class: phpbb\auth\provider\oauth\service\bitly + arguments: + - @config + - @request + tags: + - { name: auth.provider.oauth.service } + auth.provider.oauth.service.facebook: + class: phpbb\auth\provider\oauth\service\facebook + arguments: + - @config + - @request + tags: + - { name: auth.provider.oauth.service } + auth.provider.oauth.service.google: + class: phpbb\auth\provider\oauth\service\google + arguments: + - @config + - @request + tags: + - { name: auth.provider.oauth.service } diff --git a/phpBB/config/services_avatar.yml b/phpBB/config/default/services_avatar.yml similarity index 100% rename from phpBB/config/services_avatar.yml rename to phpBB/config/default/services_avatar.yml diff --git a/phpBB/config/default/services_avatars.yml b/phpBB/config/default/services_avatars.yml new file mode 100644 index 0000000000..8e5b1fdbfe --- /dev/null +++ b/phpBB/config/default/services_avatars.yml @@ -0,0 +1,60 @@ +services: + avatar.driver.gravatar: + class: phpbb\avatar\driver\gravatar + arguments: + - @config + - %core.root_path% + - %core.php_ext% + - @path_helper + - @cache.driver + calls: + - [set_name, [avatar.driver.gravatar]] + tags: + - { name: avatar.driver } + + avatar.driver.local: + class: phpbb\avatar\driver\local + arguments: + - @config + - %core.root_path% + - %core.php_ext% + - @path_helper + - @cache.driver + calls: + - [set_name, [avatar.driver.local]] + tags: + - { name: avatar.driver } + + avatar.driver.remote: + class: phpbb\avatar\driver\remote + arguments: + - @config + - %core.root_path% + - %core.php_ext% + - @path_helper + - @cache.driver + calls: + - [set_name, [avatar.driver.remote]] + tags: + - { name: avatar.driver } + + avatar.driver.upload: + class: phpbb\avatar\driver\upload + arguments: + - @config + - %core.root_path% + - %core.php_ext% + - @path_helper + - @mimetype.guesser + - @cache.driver + calls: + - [set_name, [avatar.driver.upload]] + tags: + - { name: avatar.driver } + + avatar.driver_collection: + class: phpbb\di\service_collection + arguments: + - @service_container + tags: + - { name: service_collection, tag: avatar.driver } diff --git a/phpBB/config/services_captcha.yml b/phpBB/config/default/services_captcha.yml similarity index 100% rename from phpBB/config/services_captcha.yml rename to phpBB/config/default/services_captcha.yml diff --git a/phpBB/config/services_console.yml b/phpBB/config/default/services_console.yml similarity index 100% rename from phpBB/config/services_console.yml rename to phpBB/config/default/services_console.yml diff --git a/phpBB/config/services_content.yml b/phpBB/config/default/services_content.yml similarity index 100% rename from phpBB/config/services_content.yml rename to phpBB/config/default/services_content.yml diff --git a/phpBB/config/services_cron.yml b/phpBB/config/default/services_cron.yml similarity index 100% rename from phpBB/config/services_cron.yml rename to phpBB/config/default/services_cron.yml diff --git a/phpBB/config/default/services_cron_tasks.yml b/phpBB/config/default/services_cron_tasks.yml new file mode 100644 index 0000000000..acf9a48bf9 --- /dev/null +++ b/phpBB/config/default/services_cron_tasks.yml @@ -0,0 +1,125 @@ +services: + cron.task.core.prune_all_forums: + class: phpbb\cron\task\core\prune_all_forums + arguments: + - %core.root_path% + - %core.php_ext% + - @config + - @dbal.conn + calls: + - [set_name, [cron.task.core.prune_all_forums]] + tags: + - { name: cron.task } + + cron.task.core.prune_forum: + class: phpbb\cron\task\core\prune_forum + arguments: + - %core.root_path% + - %core.php_ext% + - @config + - @dbal.conn + calls: + - [set_name, [cron.task.core.prune_forum]] + tags: + - { name: cron.task } + + cron.task.core.prune_shadow_topics: + class: phpbb\cron\task\core\prune_shadow_topics + arguments: + - %core.root_path% + - %core.php_ext% + - @config + - @dbal.conn + - @log + - @user + calls: + - [set_name, [cron.task.core.prune_shadow_topics]] + tags: + - { name: cron.task } + + cron.task.core.prune_notifications: + class: phpbb\cron\task\core\prune_notifications + arguments: + - @config + - @notification_manager + calls: + - [set_name, [cron.task.core.prune_notifications]] + tags: + - { name: cron.task } + + cron.task.core.queue: + class: phpbb\cron\task\core\queue + arguments: + - %core.root_path% + - %core.php_ext% + - @config + calls: + - [set_name, [cron.task.core.queue]] + tags: + - { name: cron.task } + + cron.task.core.tidy_cache: + class: phpbb\cron\task\core\tidy_cache + arguments: + - @config + - @cache.driver + calls: + - [set_name, [cron.task.core.tidy_cache]] + tags: + - { name: cron.task } + + cron.task.core.tidy_database: + class: phpbb\cron\task\core\tidy_database + arguments: + - %core.root_path% + - %core.php_ext% + - @config + calls: + - [set_name, [cron.task.core.tidy_database]] + tags: + - { name: cron.task } + + cron.task.core.tidy_plupload: + class: phpbb\cron\task\core\tidy_plupload + arguments: + - %core.root_path% + - @config + calls: + - [set_name, [cron.task.core.tidy_plupload]] + tags: + - { name: cron.task } + + cron.task.core.tidy_search: + class: phpbb\cron\task\core\tidy_search + arguments: + - %core.root_path% + - %core.php_ext% + - @auth + - @config + - @dbal.conn + - @user + calls: + - [set_name, [cron.task.core.tidy_search]] + tags: + - { name: cron.task } + + cron.task.core.tidy_sessions: + class: phpbb\cron\task\core\tidy_sessions + arguments: + - @config + - @user + calls: + - [set_name, [cron.task.core.tidy_sessions]] + tags: + - { name: cron.task } + + cron.task.core.tidy_warnings: + class: phpbb\cron\task\core\tidy_warnings + arguments: + - %core.root_path% + - %core.php_ext% + - @config + calls: + - [set_name, [cron.task.core.tidy_warnings]] + tags: + - { name: cron.task } diff --git a/phpBB/config/services_db.yml b/phpBB/config/default/services_db.yml similarity index 100% rename from phpBB/config/services_db.yml rename to phpBB/config/default/services_db.yml diff --git a/phpBB/config/services_event.yml b/phpBB/config/default/services_event.yml similarity index 100% rename from phpBB/config/services_event.yml rename to phpBB/config/default/services_event.yml diff --git a/phpBB/config/services_feed.yml b/phpBB/config/default/services_feed.yml similarity index 100% rename from phpBB/config/services_feed.yml rename to phpBB/config/default/services_feed.yml diff --git a/phpBB/config/default/services_migrator.yml b/phpBB/config/default/services_migrator.yml new file mode 100644 index 0000000000..cd04eea5c2 --- /dev/null +++ b/phpBB/config/default/services_migrator.yml @@ -0,0 +1,60 @@ +services: + migrator: + class: phpbb\db\migrator + arguments: + - @config + - @dbal.conn + - @dbal.tools + - %tables.migrations% + - %core.root_path% + - %core.php_ext% + - %core.table_prefix% + - @migrator.tool_collection + - @migrator.helper + + migrator.helper: + class: phpbb\db\migration\helper + + migrator.tool_collection: + class: phpbb\di\service_collection + arguments: + - @service_container + tags: + - { name: service_collection, tag: migrator.tool } + + migrator.tool.config: + class: phpbb\db\migration\tool\config + arguments: + - @config + tags: + - { name: migrator.tool } + + migrator.tool.config_text: + class: phpbb\db\migration\tool\config_text + arguments: + - @config_text + tags: + - { name: migrator.tool } + + migrator.tool.module: + class: phpbb\db\migration\tool\module + arguments: + - @dbal.conn + - @cache + - @user + - %core.root_path% + - %core.php_ext% + - %tables.modules% + tags: + - { name: migrator.tool } + + migrator.tool.permission: + class: phpbb\db\migration\tool\permission + arguments: + - @dbal.conn + - @cache + - @auth + - %core.root_path% + - %core.php_ext% + tags: + - { name: migrator.tool } diff --git a/phpBB/config/services_mimetype_guesser.yml b/phpBB/config/default/services_mimetype_guesser.yml similarity index 100% rename from phpBB/config/services_mimetype_guesser.yml rename to phpBB/config/default/services_mimetype_guesser.yml diff --git a/phpBB/config/default/services_mimetype_guessers.yml b/phpBB/config/default/services_mimetype_guessers.yml new file mode 100644 index 0000000000..0115146deb --- /dev/null +++ b/phpBB/config/default/services_mimetype_guessers.yml @@ -0,0 +1,43 @@ +parameters: + mimetype.guesser.priority.lowest: -2 + mimetype.guesser.priority.low: -1 + mimetype.guesser.priority.default: 0 + mimetype.guesser.priority.high: 1 + mimetype.guesser.priority.highest: 2 + +services: + mimetype.fileinfo_mimetype_guesser: + class: Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser + tags: + - { name: mimetype.guessers } + + mimetype.filebinary_mimetype_guesser: + class: Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser + tags: + - { name: mimetype.guessers } + + mimetype.content_guesser: + class: phpbb\mimetype\content_guesser + calls: + - [set_priority, [%mimetype.guesser.priority.low%]] + tags: + - { name: mimetype.guessers } + + mimetype.extension_guesser: + class: phpbb\mimetype\extension_guesser + calls: + - [set_priority, [%mimetype.guesser.priority.lowest%]] + tags: + - { name: mimetype.guessers } + + mimetype.guesser_collection: + class: phpbb\di\service_collection + arguments: + - @service_container + tags: + - { name: service_collection, tag: mimetype.guessers } + + mimetype.guesser: + class: phpbb\mimetype\guesser + arguments: + - @mimetype.guesser_collection diff --git a/phpBB/config/services_notification.yml b/phpBB/config/default/services_notification.yml similarity index 100% rename from phpBB/config/services_notification.yml rename to phpBB/config/default/services_notification.yml diff --git a/phpBB/config/default/services_notifications.yml b/phpBB/config/default/services_notifications.yml new file mode 100644 index 0000000000..5675e76a99 --- /dev/null +++ b/phpBB/config/default/services_notifications.yml @@ -0,0 +1,368 @@ +services: + notification.type_collection: + class: phpbb\di\service_collection + arguments: + - @service_container + tags: + - { name: service_collection, tag: notification.type } + + notification.method_collection: + class: phpbb\di\service_collection + arguments: + - @service_container + tags: + - { name: service_collection, tag: notification.method } + + notification.type.approve_post: + class: phpbb\notification\type\approve_post + scope: prototype # scope MUST be prototype for this to work! # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } + + notification.type.approve_topic: + class: phpbb\notification\type\approve_topic + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } + + notification.type.bookmark: + class: phpbb\notification\type\bookmark + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } + + notification.type.disapprove_post: + class: phpbb\notification\type\disapprove_post + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } + + notification.type.disapprove_topic: + class: phpbb\notification\type\disapprove_topic + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } + + notification.type.group_request: + class: phpbb\notification\type\group_request + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } + + notification.type.group_request_approved: + class: phpbb\notification\type\group_request_approved + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } + + notification.type.pm: + class: phpbb\notification\type\pm + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } + + notification.type.post: + class: phpbb\notification\type\post + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } + + notification.type.post_in_queue: + class: phpbb\notification\type\post_in_queue + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } + + notification.type.quote: + class: phpbb\notification\type\quote + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } + + notification.type.report_pm: + class: phpbb\notification\type\report_pm + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } + + notification.type.report_pm_closed: + class: phpbb\notification\type\report_pm_closed + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } + + notification.type.report_post: + class: phpbb\notification\type\report_post + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } + + notification.type.report_post_closed: + class: phpbb\notification\type\report_post_closed + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } + + notification.type.topic: + class: phpbb\notification\type\topic + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } + + notification.type.topic_in_queue: + class: phpbb\notification\type\topic_in_queue + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } + + notification.type.admin_activate_user: + class: phpbb\notification\type\admin_activate_user + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } + + notification.method.email: + class: phpbb\notification\method\email + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - %core.root_path% + - %core.php_ext% + tags: + - { name: notification.method } + + notification.method.jabber: + class: phpbb\notification\method\jabber + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - %core.root_path% + - %core.php_ext% + tags: + - { name: notification.method } diff --git a/phpBB/config/services_password.yml b/phpBB/config/default/services_password.yml similarity index 100% rename from phpBB/config/services_password.yml rename to phpBB/config/default/services_password.yml diff --git a/phpBB/config/default/services_passwords.yml b/phpBB/config/default/services_passwords.yml new file mode 100644 index 0000000000..3dc217286f --- /dev/null +++ b/phpBB/config/default/services_passwords.yml @@ -0,0 +1,128 @@ +parameters: + passwords.algorithms: + - passwords.driver.bcrypt_2y + - passwords.driver.bcrypt + - passwords.driver.salted_md5 + - passwords.driver.phpass + +services: + passwords.driver.bcrypt: + class: phpbb\passwords\driver\bcrypt + arguments: + - @config + - @passwords.driver_helper + tags: + - { name: passwords.driver } + + passwords.driver.bcrypt_2y: + class: phpbb\passwords\driver\bcrypt_2y + arguments: + - @config + - @passwords.driver_helper + tags: + - { name: passwords.driver } + + passwords.driver.bcrypt_wcf2: + class: phpbb\passwords\driver\bcrypt_wcf2 + arguments: + - @passwords.driver.bcrypt + - @passwords.driver_helper + tags: + - { name: passwords.driver } + + passwords.driver.salted_md5: + class: phpbb\passwords\driver\salted_md5 + arguments: + - @config + - @passwords.driver_helper + tags: + - { name: passwords.driver } + + passwords.driver.phpass: + class: phpbb\passwords\driver\phpass + arguments: + - @config + - @passwords.driver_helper + tags: + - { name: passwords.driver } + + passwords.driver.convert_password: + class: phpbb\passwords\driver\convert_password + arguments: + - @config + - @passwords.driver_helper + tags: + - { name: passwords.driver } + + passwords.driver.sha1_smf: + class: phpbb\passwords\driver\sha1_smf + arguments: + - @config + - @passwords.driver_helper + tags: + - { name: passwords.driver } + + passwords.driver.sha1_wcf1: + class: phpbb\passwords\driver\sha1_wcf1 + arguments: + - @config + - @passwords.driver_helper + tags: + - { name: passwords.driver } + + passwords.driver.sha1: + class: phpbb\passwords\driver\sha1 + arguments: + - @config + - @passwords.driver_helper + tags: + - { name: passwords.driver } + + passwords.driver.md5_phpbb2: + class: phpbb\passwords\driver\md5_phpbb2 + arguments: + - @request + - @passwords.driver.salted_md5 + - %core.root_path% + - %core.php_ext% + tags: + - { name: passwords.driver } + + passwords.driver.md5_mybb: + class: phpbb\passwords\driver\md5_mybb + arguments: + - @config + - @passwords.driver_helper + tags: + - { name: passwords.driver } + + passwords.driver.md5_vb: + class: phpbb\passwords\driver\md5_vb + arguments: + - @config + - @passwords.driver_helper + tags: + - { name: passwords.driver } + + passwords.driver_collection: + class: phpbb\di\service_collection + arguments: + - @service_container + tags: + - { name: service_collection, tag: passwords.driver } + + passwords.driver_helper: + class: phpbb\passwords\driver\helper + arguments: + - @config + + passwords.manager: + class: phpbb\passwords\manager + arguments: + - @config + - @passwords.driver_collection + - @passwords.helper + - %passwords.algorithms% + + passwords.helper: + class: phpbb\passwords\helper diff --git a/phpBB/config/services_profilefield.yml b/phpBB/config/default/services_profilefield.yml similarity index 100% rename from phpBB/config/services_profilefield.yml rename to phpBB/config/default/services_profilefield.yml diff --git a/phpBB/config/default/services_profilefields.yml b/phpBB/config/default/services_profilefields.yml new file mode 100644 index 0000000000..ce2a84b12b --- /dev/null +++ b/phpBB/config/default/services_profilefields.yml @@ -0,0 +1,101 @@ +services: + profilefields.manager: + class: phpbb\profilefields\manager + arguments: + - @auth + - @dbal.conn + - @dispatcher + - @request + - @template + - @profilefields.type_collection + - @user + - %tables.profile_fields% + - %tables.profile_fields_language% + - %tables.profile_fields_data% + + profilefields.lang_helper: + class: phpbb\profilefields\lang_helper + arguments: + - @dbal.conn + - %tables.profile_fields_options_language% + + profilefields.type_collection: + class: phpbb\di\service_collection + arguments: + - @service_container + tags: + - { name: service_collection, tag: profilefield.type } + + profilefields.type.bool: + class: phpbb\profilefields\type\type_bool + arguments: + - @profilefields.lang_helper + - @request + - @template + - @user + tags: + - { name: profilefield.type } + + profilefields.type.date: + class: phpbb\profilefields\type\type_date + arguments: + - @request + - @template + - @user + tags: + - { name: profilefield.type } + + profilefields.type.dropdown: + class: phpbb\profilefields\type\type_dropdown + arguments: + - @profilefields.lang_helper + - @request + - @template + - @user + tags: + - { name: profilefield.type } + + profilefields.type.googleplus: + class: phpbb\profilefields\type\type_googleplus + arguments: + - @request + - @template + - @user + tags: + - { name: profilefield.type } + + profilefields.type.int: + class: phpbb\profilefields\type\type_int + arguments: + - @request + - @template + - @user + tags: + - { name: profilefield.type } + + profilefields.type.string: + class: phpbb\profilefields\type\type_string + arguments: + - @request + - @template + - @user + tags: + - { name: profilefield.type } + + profilefields.type.text: + class: phpbb\profilefields\type\type_text + arguments: + - @request + - @template + - @user + tags: + - { name: profilefield.type } + + profilefields.type.url: + class: phpbb\profilefields\type\type_url + arguments: + - @request + - @template + - @user + tags: + - { name: profilefield.type } diff --git a/phpBB/config/services_twig.yml b/phpBB/config/default/services_twig.yml similarity index 100% rename from phpBB/config/services_twig.yml rename to phpBB/config/default/services_twig.yml diff --git a/phpBB/config/services_user.yml b/phpBB/config/default/services_user.yml similarity index 100% rename from phpBB/config/services_user.yml rename to phpBB/config/default/services_user.yml diff --git a/phpBB/config/tables.yml b/phpBB/config/default/tables.yml similarity index 100% rename from phpBB/config/tables.yml rename to phpBB/config/default/tables.yml diff --git a/phpBB/config/development/environment.yml b/phpBB/config/development/environment.yml new file mode 100644 index 0000000000..6342885067 --- /dev/null +++ b/phpBB/config/development/environment.yml @@ -0,0 +1,2 @@ +imports: + - { resource: ../default/services.yml } diff --git a/phpBB/config/environment_development.yml b/phpBB/config/environment_development.yml deleted file mode 100644 index 6982aa4f83..0000000000 --- a/phpBB/config/environment_development.yml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: services.yml } diff --git a/phpBB/config/environment_production.yml b/phpBB/config/environment_production.yml deleted file mode 100644 index 6982aa4f83..0000000000 --- a/phpBB/config/environment_production.yml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: services.yml } diff --git a/phpBB/config/production/environment.yml b/phpBB/config/production/environment.yml new file mode 100644 index 0000000000..6342885067 --- /dev/null +++ b/phpBB/config/production/environment.yml @@ -0,0 +1,2 @@ +imports: + - { resource: ../default/services.yml } diff --git a/phpBB/phpbb/di/extension/core.php b/phpBB/phpbb/di/extension/core.php index 5fb8d9ad34..cff0a1e76e 100644 --- a/phpBB/phpbb/di/extension/core.php +++ b/phpBB/phpbb/di/extension/core.php @@ -50,7 +50,7 @@ class core extends Extension public function load(array $config, ContainerBuilder $container) { $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->config_path))); - $loader->load('environment_' . ENVIRONMENT . '.yml'); + $loader->load(ENVIRONMENT . '/environment.yml'); } /** From 42c9fd5c76aa6f2757ed3366729b2d0e48c3333d Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 20 Jun 2014 18:56:55 +0200 Subject: [PATCH 10/37] [ticket/12620] Add inheritance between environments PHPBB3-12620 --- phpBB/config/default/parameters.yml | 0 phpBB/config/development/environment.yml | 3 ++- phpBB/config/development/parameters.yml | 2 ++ phpBB/config/development/services.yml | 2 ++ phpBB/config/production/environment.yml | 3 ++- phpBB/config/production/parameters.yml | 2 ++ phpBB/config/production/services.yml | 2 ++ 7 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 phpBB/config/default/parameters.yml create mode 100644 phpBB/config/development/parameters.yml create mode 100644 phpBB/config/development/services.yml create mode 100644 phpBB/config/production/parameters.yml create mode 100644 phpBB/config/production/services.yml diff --git a/phpBB/config/default/parameters.yml b/phpBB/config/default/parameters.yml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/phpBB/config/development/environment.yml b/phpBB/config/development/environment.yml index 6342885067..40a3c7a683 100644 --- a/phpBB/config/development/environment.yml +++ b/phpBB/config/development/environment.yml @@ -1,2 +1,3 @@ imports: - - { resource: ../default/services.yml } + - { resource: services.yml } + - { resource: parameters.yml } diff --git a/phpBB/config/development/parameters.yml b/phpBB/config/development/parameters.yml new file mode 100644 index 0000000000..02743729f9 --- /dev/null +++ b/phpBB/config/development/parameters.yml @@ -0,0 +1,2 @@ +imports: + - { resource: ../default/parameters.yml } diff --git a/phpBB/config/development/services.yml b/phpBB/config/development/services.yml new file mode 100644 index 0000000000..6342885067 --- /dev/null +++ b/phpBB/config/development/services.yml @@ -0,0 +1,2 @@ +imports: + - { resource: ../default/services.yml } diff --git a/phpBB/config/production/environment.yml b/phpBB/config/production/environment.yml index 6342885067..40a3c7a683 100644 --- a/phpBB/config/production/environment.yml +++ b/phpBB/config/production/environment.yml @@ -1,2 +1,3 @@ imports: - - { resource: ../default/services.yml } + - { resource: services.yml } + - { resource: parameters.yml } diff --git a/phpBB/config/production/parameters.yml b/phpBB/config/production/parameters.yml new file mode 100644 index 0000000000..02743729f9 --- /dev/null +++ b/phpBB/config/production/parameters.yml @@ -0,0 +1,2 @@ +imports: + - { resource: ../default/parameters.yml } diff --git a/phpBB/config/production/services.yml b/phpBB/config/production/services.yml new file mode 100644 index 0000000000..6342885067 --- /dev/null +++ b/phpBB/config/production/services.yml @@ -0,0 +1,2 @@ +imports: + - { resource: ../default/services.yml } From d2822af6d7fb6e1d8d67d9c8b758ecedb1d67b58 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 9 Aug 2014 16:46:16 +0200 Subject: [PATCH 11/37] [ticket/12620] Rebased to the latest develop-ascraeus PHPBB3-12620 --- phpBB/common.php | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/common.php b/phpBB/common.php index a1142e4af4..2332802f30 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -107,7 +107,6 @@ if (ENVIRONMENT == 'debug' && !class_exists('Goutte\Client', true)) phpbb_load_extensions_autoloaders($phpbb_root_path); // Set up container -$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx); try { $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_config_php_file, $phpbb_root_path, $phpEx); From 3f678af5f34d9fd9a635d6ce82bd41285ff71be1 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 10 Aug 2014 12:06:50 +0200 Subject: [PATCH 12/37] [ticket/12620] Update tests PHPBB3-12620 --- .../fixtures/config/{services.yml => production/environment.yml} | 0 .../other_config/{services.yml => production/environment.yml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/di/fixtures/config/{services.yml => production/environment.yml} (100%) rename tests/di/fixtures/other_config/{services.yml => production/environment.yml} (100%) diff --git a/tests/di/fixtures/config/services.yml b/tests/di/fixtures/config/production/environment.yml similarity index 100% rename from tests/di/fixtures/config/services.yml rename to tests/di/fixtures/config/production/environment.yml diff --git a/tests/di/fixtures/other_config/services.yml b/tests/di/fixtures/other_config/production/environment.yml similarity index 100% rename from tests/di/fixtures/other_config/services.yml rename to tests/di/fixtures/other_config/production/environment.yml From 143dfa28c62bce5292c9840766f56d9f288980b5 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 15 Aug 2014 19:15:18 +0200 Subject: [PATCH 13/37] [ticket/12620] Rebased on develop PHPBB3-12620 --- phpBB/config/default/parameters.yml | 20 ++++++++++++++++++++ phpBB/config/parameters.yml | 20 -------------------- 2 files changed, 20 insertions(+), 20 deletions(-) delete mode 100644 phpBB/config/parameters.yml diff --git a/phpBB/config/default/parameters.yml b/phpBB/config/default/parameters.yml index e69de29bb2..8ecc1428f4 100644 --- a/phpBB/config/default/parameters.yml +++ b/phpBB/config/default/parameters.yml @@ -0,0 +1,20 @@ +parameters: + # Disable the usage of the super globals (_GET, _POST, _SERVER...) + core.disable_super_globals: true + + # Datetime class to use + datetime.class: \phpbb\datetime + + # Mimetype guesser priorities + mimetype.guesser.priority.lowest: -2 + mimetype.guesser.priority.low: -1 + mimetype.guesser.priority.default: 0 + mimetype.guesser.priority.high: 1 + mimetype.guesser.priority.highest: 2 + + # List of default password driver types + passwords.algorithms: + - passwords.driver.bcrypt_2y + - passwords.driver.bcrypt + - passwords.driver.salted_md5 + - passwords.driver.phpass diff --git a/phpBB/config/parameters.yml b/phpBB/config/parameters.yml deleted file mode 100644 index 8ecc1428f4..0000000000 --- a/phpBB/config/parameters.yml +++ /dev/null @@ -1,20 +0,0 @@ -parameters: - # Disable the usage of the super globals (_GET, _POST, _SERVER...) - core.disable_super_globals: true - - # Datetime class to use - datetime.class: \phpbb\datetime - - # Mimetype guesser priorities - mimetype.guesser.priority.lowest: -2 - mimetype.guesser.priority.low: -1 - mimetype.guesser.priority.default: 0 - mimetype.guesser.priority.high: 1 - mimetype.guesser.priority.highest: 2 - - # List of default password driver types - passwords.algorithms: - - passwords.driver.bcrypt_2y - - passwords.driver.bcrypt - - passwords.driver.salted_md5 - - passwords.driver.phpass From b697273aaa53d9f9f4a3d4a53cc6267e906953cd Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 4 Sep 2014 17:06:39 +0200 Subject: [PATCH 14/37] [ticket/12620] Use PHPBB_ENVIRONMENT PHPBB3-12620 --- phpBB/common.php | 8 ++++---- phpBB/includes/functions_install.php | 4 ++-- phpBB/install/index.php | 2 +- phpBB/phpbb/di/extension/core.php | 2 +- tests/di/create_container_test.php | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/phpBB/common.php b/phpBB/common.php index 2332802f30..85568ab10e 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -29,9 +29,9 @@ $phpbb_class_loader->register(); $phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx); extract($phpbb_config_php_file->get_all()); -if (!defined('ENVIRONMENT')) +if (!defined('PHPBB_ENVIRONMENT')) { - @define('ENVIRONMENT', 'production'); + @define('PHPBB_ENVIRONMENT', 'production'); } if (!defined('PHPBB_INSTALLED')) @@ -96,7 +96,7 @@ set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handle $phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx); $phpbb_class_loader_ext->register(); -if (ENVIRONMENT == 'debug' && !class_exists('Goutte\Client', true)) +if (PHPBB_ENVIRONMENT == 'debug' && !class_exists('Goutte\Client', true)) { trigger_error( 'Composer development dependencies have not been set up for the development environment yet, run ' . @@ -115,7 +115,7 @@ try catch (InvalidArgumentException $e) { trigger_error( - 'The requested environment ' . ENVIRONMENT . ' is not available.', + 'The requested environment ' . PHPBB_ENVIRONMENT . ' is not available.', E_USER_ERROR ); } diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index e0ecda3bfa..cdd9c7864b 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -453,11 +453,11 @@ function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_cont if ($debug) { - $config_data .= "@define('ENVIRONMENT', 'development');\n"; + $config_data .= "@define('PHPBB_ENVIRONMENT', 'development');\n"; } else { - $config_data .= "@define('ENVIRONMENT', 'production');\n"; + $config_data .= "@define('PHPBB_ENVIRONMENT', 'production');\n"; } if ($debug_container) diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 8edc447492..1cc588071b 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -16,7 +16,7 @@ */ define('IN_PHPBB', true); define('IN_INSTALL', true); -define('ENVIRONMENT', 'production'); +define('PHPBB_ENVIRONMENT', 'production'); /**#@-*/ $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../'; diff --git a/phpBB/phpbb/di/extension/core.php b/phpBB/phpbb/di/extension/core.php index cff0a1e76e..7787602aba 100644 --- a/phpBB/phpbb/di/extension/core.php +++ b/phpBB/phpbb/di/extension/core.php @@ -50,7 +50,7 @@ class core extends Extension public function load(array $config, ContainerBuilder $container) { $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->config_path))); - $loader->load(ENVIRONMENT . '/environment.yml'); + $loader->load(PHPBB_ENVIRONMENT . '/environment.yml'); } /** diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index 2ddbf68f39..ecfe504775 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -13,7 +13,7 @@ namespace { - define('ENVIRONMENT', 'production'); + define('PHPBB_ENVIRONMENT', 'production'); require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; From 0306fefe04ca987caa1a04bcc105ba76e8d01d9a Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 5 Sep 2014 01:59:55 +0200 Subject: [PATCH 15/37] [ticket/12620] Move the routing file to the environments PHPBB3-12620 --- phpBB/config/{ => default}/routing.yml | 0 phpBB/config/development/routing.yml | 2 ++ phpBB/config/production/routing.yml | 2 ++ 3 files changed, 4 insertions(+) rename phpBB/config/{ => default}/routing.yml (100%) create mode 100644 phpBB/config/development/routing.yml create mode 100644 phpBB/config/production/routing.yml diff --git a/phpBB/config/routing.yml b/phpBB/config/default/routing.yml similarity index 100% rename from phpBB/config/routing.yml rename to phpBB/config/default/routing.yml diff --git a/phpBB/config/development/routing.yml b/phpBB/config/development/routing.yml new file mode 100644 index 0000000000..9ee3e5ae3a --- /dev/null +++ b/phpBB/config/development/routing.yml @@ -0,0 +1,2 @@ +core.default: + resource: "../default/routing.yml" diff --git a/phpBB/config/production/routing.yml b/phpBB/config/production/routing.yml new file mode 100644 index 0000000000..9ee3e5ae3a --- /dev/null +++ b/phpBB/config/production/routing.yml @@ -0,0 +1,2 @@ +core.default: + resource: "../default/routing.yml" From 0bf3d2d962c33ffa606d38e91d04665b78fbd8bc Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 5 Sep 2014 02:29:15 +0200 Subject: [PATCH 16/37] [ticket/12620] Add the support of the environments for the ext services We look for an environment.yml file in the config/PHPBB_ENVIRONMENT/ directory of the extensionss. If the directory does not exist we look for the environment.yml file in the 'default' environment and finally for the services.yml file in the config/ directory. PHPBB3-12620 --- phpBB/phpbb/di/extension/ext.php | 28 +++++++++++++++++-- tests/di/create_container_test.php | 4 +++ .../environment.yml} | 0 .../config/production/environment.yml | 2 ++ .../ext/vendor/enabled-3/config/services.yml | 2 ++ .../{services.yml => default/environment.yml} | 0 6 files changed, 33 insertions(+), 3 deletions(-) rename tests/di/fixtures/ext/vendor/disabled/config/{services.yml => production/environment.yml} (100%) create mode 100644 tests/di/fixtures/ext/vendor/enabled-2/config/production/environment.yml create mode 100644 tests/di/fixtures/ext/vendor/enabled-3/config/services.yml rename tests/di/fixtures/ext/vendor/enabled/config/{services.yml => default/environment.yml} (100%) diff --git a/phpBB/phpbb/di/extension/ext.php b/phpBB/phpbb/di/extension/ext.php index 718c992d2e..330303ca0c 100644 --- a/phpBB/phpbb/di/extension/ext.php +++ b/phpBB/phpbb/di/extension/ext.php @@ -45,10 +45,32 @@ class ext extends Extension { foreach ($this->paths as $path) { - if (file_exists($path . '/config/services.yml')) + $services_directory = false; + $services_file = false; + + if (file_exists($path . 'config/' . PHPBB_ENVIRONMENT . '/environment.yml')) { - $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($path . '/config'))); - $loader->load('services.yml'); + $services_directory = $path . 'config/' . PHPBB_ENVIRONMENT; + $services_file = 'environment.yml'; + } + else if (!is_dir($path . 'config/' . PHPBB_ENVIRONMENT)) + { + if (file_exists($path . 'config/default/environment.yml')) + { + $services_directory = $path . 'config/default'; + $services_file = 'environment.yml'; + } + else if (!is_dir($path . 'config/default') && file_exists($path . '/config/services.yml')) + { + $services_directory = $path . 'config'; + $services_file = 'services.yml'; + } + } + + if ($services_directory && $services_file) + { + $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($services_directory))); + $loader->load($services_file); } } } diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index ecfe504775..ec9828debb 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -59,6 +59,8 @@ namespace // Checks use_extensions $this->assertTrue($container->hasParameter('enabled')); + $this->assertTrue($container->hasParameter('enabled_2')); + $this->assertTrue($container->hasParameter('enabled_3')); $this->assertFalse($container->hasParameter('disabled')); $this->assertFalse($container->hasParameter('available')); @@ -201,6 +203,8 @@ namespace phpbb\db\driver { return array( array('ext_name' => 'vendor/enabled'), + array('ext_name' => 'vendor/enabled-2'), + array('ext_name' => 'vendor/enabled-3'), ); } } diff --git a/tests/di/fixtures/ext/vendor/disabled/config/services.yml b/tests/di/fixtures/ext/vendor/disabled/config/production/environment.yml similarity index 100% rename from tests/di/fixtures/ext/vendor/disabled/config/services.yml rename to tests/di/fixtures/ext/vendor/disabled/config/production/environment.yml diff --git a/tests/di/fixtures/ext/vendor/enabled-2/config/production/environment.yml b/tests/di/fixtures/ext/vendor/enabled-2/config/production/environment.yml new file mode 100644 index 0000000000..feeb5a7a2d --- /dev/null +++ b/tests/di/fixtures/ext/vendor/enabled-2/config/production/environment.yml @@ -0,0 +1,2 @@ +parameters: + enabled_2: true diff --git a/tests/di/fixtures/ext/vendor/enabled-3/config/services.yml b/tests/di/fixtures/ext/vendor/enabled-3/config/services.yml new file mode 100644 index 0000000000..0dae35d2bd --- /dev/null +++ b/tests/di/fixtures/ext/vendor/enabled-3/config/services.yml @@ -0,0 +1,2 @@ +parameters: + enabled_3: true diff --git a/tests/di/fixtures/ext/vendor/enabled/config/services.yml b/tests/di/fixtures/ext/vendor/enabled/config/default/environment.yml similarity index 100% rename from tests/di/fixtures/ext/vendor/enabled/config/services.yml rename to tests/di/fixtures/ext/vendor/enabled/config/default/environment.yml From 7cd0fd83b8047f40edfb69a427b14997801ef25b Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 5 Sep 2014 03:03:20 +0200 Subject: [PATCH 17/37] [ticket/12620] Fix tests PHPBB3-12620 --- tests/bootstrap.php | 2 ++ tests/controller/config/{ => production}/routing.yml | 0 tests/pagination/config/{ => production}/routing.yml | 0 3 files changed, 2 insertions(+) rename tests/controller/config/{ => production}/routing.yml (100%) rename tests/pagination/config/{ => production}/routing.yml (100%) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 0e81f4372a..229a6ee82b 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -12,6 +12,8 @@ */ define('IN_PHPBB', true); +define('PHPBB_ENVIRONMENT', 'production'); + $phpbb_root_path = 'phpBB/'; $phpEx = 'php'; require_once $phpbb_root_path . 'includes/startup.php'; diff --git a/tests/controller/config/routing.yml b/tests/controller/config/production/routing.yml similarity index 100% rename from tests/controller/config/routing.yml rename to tests/controller/config/production/routing.yml diff --git a/tests/pagination/config/routing.yml b/tests/pagination/config/production/routing.yml similarity index 100% rename from tests/pagination/config/routing.yml rename to tests/pagination/config/production/routing.yml From 014eed385bf761d9e3f0992835f44f58bf055afd Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 5 Sep 2014 16:33:57 +0200 Subject: [PATCH 18/37] [ticket/12620] Add support of the environments for the ext routing files PHPBB3-12620 --- phpBB/bin/phpbbcli.php | 6 ++++++ phpBB/includes/functions_url_matcher.php | 4 ++-- tests/controller/common_helper_route.php | 6 ------ tests/controller/controller_test.php | 8 ++++++++ .../vendor2/bar/config/production/routing.yml | 3 +++ .../ext/vendor2/bar/config/services.yml | 3 +++ .../controller/ext/vendor2/bar/controller.php | 18 ++++++++++++++++++ 7 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 tests/controller/ext/vendor2/bar/config/production/routing.yml create mode 100644 tests/controller/ext/vendor2/bar/config/services.yml create mode 100644 tests/controller/ext/vendor2/bar/controller.php diff --git a/phpBB/bin/phpbbcli.php b/phpBB/bin/phpbbcli.php index ca425ad0c4..14681e25ee 100755 --- a/phpBB/bin/phpbbcli.php +++ b/phpBB/bin/phpbbcli.php @@ -21,6 +21,12 @@ if (php_sapi_name() != 'cli') } define('IN_PHPBB', true); + +if (!defined('PHPBB_ENVIRONMENT')) +{ + @define('PHPBB_ENVIRONMENT', 'production'); +} + $phpbb_root_path = __DIR__ . '/../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); require($phpbb_root_path . 'includes/startup.' . $phpEx); diff --git a/phpBB/includes/functions_url_matcher.php b/phpBB/includes/functions_url_matcher.php index b965046aad..3d977a5daf 100644 --- a/phpBB/includes/functions_url_matcher.php +++ b/phpBB/includes/functions_url_matcher.php @@ -58,7 +58,7 @@ function phpbb_get_url_matcher(\phpbb\extension\manager $manager, RequestContext function phpbb_create_dumped_url_matcher(\phpbb\extension\manager $manager, $root_path, $php_ext) { $provider = new \phpbb\controller\provider(); - $provider->find_routing_files($manager->get_finder()); + $provider->find_routing_files($manager->all_enabled()); $routes = $provider->find($root_path)->get_routes(); $dumper = new PhpMatcherDumper($routes); $cached_url_matcher_dump = $dumper->dump(array( @@ -78,7 +78,7 @@ function phpbb_create_dumped_url_matcher(\phpbb\extension\manager $manager, $roo function phpbb_create_url_matcher(\phpbb\extension\manager $manager, RequestContext $context, $root_path) { $provider = new \phpbb\controller\provider(); - $provider->find_routing_files($manager->get_finder()); + $provider->find_routing_files($manager->all_enabled()); $routes = $provider->find($root_path)->get_routes(); return new UrlMatcher($routes, $context); } diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 028a73d70d..5baa846ec3 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -113,12 +113,6 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case ) ); - $finder = new \phpbb\finder( - new \phpbb\filesystem(), - dirname(__FILE__) . '/', - new phpbb_mock_cache() - ); - $finder->set_extensions(array_keys($this->extension_manager->all_enabled())); $this->router = new phpbb_mock_router($this->extension_manager, dirname(__FILE__) . '/', 'php'); $this->router->find_routing_files($finder); $this->router->find(dirname(__FILE__) . '/'); diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index cd90dda751..637e9685e6 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -30,6 +30,11 @@ class phpbb_controller_controller_test extends phpbb_test_case 'ext_active' => '1', 'ext_path' => 'ext/vendor2/foo/', ), + 'vendor2/bar' => array( + 'ext_name' => 'vendor2/bar', + 'ext_active' => '1', + 'ext_path' => 'ext/vendor2/bar/', + ), )); } @@ -49,6 +54,9 @@ class phpbb_controller_controller_test extends phpbb_test_case $this->assertInstanceOf('Symfony\Component\Routing\Route', $routes->get('controller2')); $this->assertEquals('/foo/bar', $routes->get('controller2')->getPath()); + $this->assertInstanceOf('Symfony\Component\Routing\Route', $routes->get('controller3')); + $this->assertEquals('/bar', $routes->get('controller3')->getPath()); + $this->assertNull($routes->get('controller_noroute')); } diff --git a/tests/controller/ext/vendor2/bar/config/production/routing.yml b/tests/controller/ext/vendor2/bar/config/production/routing.yml new file mode 100644 index 0000000000..85c93b453f --- /dev/null +++ b/tests/controller/ext/vendor2/bar/config/production/routing.yml @@ -0,0 +1,3 @@ +controller3: + pattern: /bar + defaults: { _controller: bar.controller:handle } diff --git a/tests/controller/ext/vendor2/bar/config/services.yml b/tests/controller/ext/vendor2/bar/config/services.yml new file mode 100644 index 0000000000..05a8a1994d --- /dev/null +++ b/tests/controller/ext/vendor2/bar/config/services.yml @@ -0,0 +1,3 @@ +services: + bar.controller: + class: bar\controller diff --git a/tests/controller/ext/vendor2/bar/controller.php b/tests/controller/ext/vendor2/bar/controller.php new file mode 100644 index 0000000000..ad35f5a051 --- /dev/null +++ b/tests/controller/ext/vendor2/bar/controller.php @@ -0,0 +1,18 @@ + Date: Mon, 29 Sep 2014 15:39:15 +0200 Subject: [PATCH 19/37] [ticket/12620] Fix download/file.php and app.php outside of the root_path PHPBB3-12620 --- phpBB/download/file.php | 5 +++++ phpBB/includes/functions_url_matcher.php | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/phpBB/download/file.php b/phpBB/download/file.php index 77fb455bc1..4b8309c70e 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -42,6 +42,11 @@ if (isset($_GET['avatar'])) $phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx); extract($phpbb_config_php_file->get_all()); + if (!defined('PHPBB_ENVIRONMENT')) + { + @define('PHPBB_ENVIRONMENT', 'production'); + } + if (!defined('PHPBB_INSTALLED') || empty($dbms) || empty($acm_type)) { exit; diff --git a/phpBB/includes/functions_url_matcher.php b/phpBB/includes/functions_url_matcher.php index 3d977a5daf..3bbc1cc924 100644 --- a/phpBB/includes/functions_url_matcher.php +++ b/phpBB/includes/functions_url_matcher.php @@ -57,9 +57,9 @@ function phpbb_get_url_matcher(\phpbb\extension\manager $manager, RequestContext */ function phpbb_create_dumped_url_matcher(\phpbb\extension\manager $manager, $root_path, $php_ext) { - $provider = new \phpbb\controller\provider(); + $provider = new \phpbb\controller\provider($root_path); $provider->find_routing_files($manager->all_enabled()); - $routes = $provider->find($root_path)->get_routes(); + $routes = $provider->find()->get_routes(); $dumper = new PhpMatcherDumper($routes); $cached_url_matcher_dump = $dumper->dump(array( 'class' => 'phpbb_url_matcher', @@ -77,9 +77,9 @@ function phpbb_create_dumped_url_matcher(\phpbb\extension\manager $manager, $roo */ function phpbb_create_url_matcher(\phpbb\extension\manager $manager, RequestContext $context, $root_path) { - $provider = new \phpbb\controller\provider(); + $provider = new \phpbb\controller\provider($root_path); $provider->find_routing_files($manager->all_enabled()); - $routes = $provider->find($root_path)->get_routes(); + $routes = $provider->find()->get_routes(); return new UrlMatcher($routes, $context); } From aa061aa7c9187009f220e62252a53b49dad7644a Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 29 Sep 2014 16:06:56 +0200 Subject: [PATCH 20/37] [ticket/12620] Uses a cache directory per environment PHPBB3-12620 --- phpBB/config/default/services_twig.yml | 2 +- phpBB/includes/functions_url_matcher.php | 33 +++--------- phpBB/phpbb/cache/driver/file.php | 7 ++- phpBB/phpbb/di/container_builder.php | 68 +++++++++++++++++++----- 4 files changed, 69 insertions(+), 41 deletions(-) diff --git a/phpBB/config/default/services_twig.yml b/phpBB/config/default/services_twig.yml index 0745d8b47e..06ce5bc15c 100644 --- a/phpBB/config/default/services_twig.yml +++ b/phpBB/config/default/services_twig.yml @@ -1,5 +1,5 @@ parameters: - core.template.cache_path: %core.root_path%cache/twig/ + core.template.cache_path: %core.root_path%cache/%environment%/twig/ services: template.twig.environment: diff --git a/phpBB/includes/functions_url_matcher.php b/phpBB/includes/functions_url_matcher.php index 3bbc1cc924..c06f4f6cb1 100644 --- a/phpBB/includes/functions_url_matcher.php +++ b/phpBB/includes/functions_url_matcher.php @@ -11,6 +11,7 @@ * */ +use Symfony\Component\Config\ConfigCache; use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper; use Symfony\Component\Routing\Matcher\UrlMatcher; use Symfony\Component\Routing\RequestContext; @@ -34,14 +35,10 @@ if (!defined('IN_PHPBB')) */ function phpbb_get_url_matcher(\phpbb\extension\manager $manager, RequestContext $context, $root_path, $php_ext) { - if (defined('DEBUG')) + $config_cache = new ConfigCache($root_path . 'cache/' . PHPBB_ENVIRONMENT . '/url_matcher.' . $php_ext, defined('DEBUG')); + if (!$config_cache->isFresh()) { - return phpbb_create_url_matcher($manager, $context, $root_path); - } - - if (!phpbb_url_matcher_dumped($root_path, $php_ext)) - { - phpbb_create_dumped_url_matcher($manager, $root_path, $php_ext); + phpbb_create_dumped_url_matcher($manager, $root_path, $config_cache); } return phpbb_load_url_matcher($context, $root_path, $php_ext); @@ -52,10 +49,10 @@ function phpbb_get_url_matcher(\phpbb\extension\manager $manager, RequestContext * * @param \phpbb\extension\manager $manager Extension manager * @param string $root_path Root path -* @param string $php_ext PHP file extension + * @param ConfigCache $config_cache The config cache * @return null */ -function phpbb_create_dumped_url_matcher(\phpbb\extension\manager $manager, $root_path, $php_ext) +function phpbb_create_dumped_url_matcher(\phpbb\extension\manager $manager, $root_path, $config_cache) { $provider = new \phpbb\controller\provider($root_path); $provider->find_routing_files($manager->all_enabled()); @@ -65,7 +62,7 @@ function phpbb_create_dumped_url_matcher(\phpbb\extension\manager $manager, $roo 'class' => 'phpbb_url_matcher', )); - file_put_contents($root_path . 'cache/url_matcher.' . $php_ext, $cached_url_matcher_dump); + $config_cache->write($cached_url_matcher_dump, $routes->getResources()); } /** @@ -93,20 +90,6 @@ function phpbb_create_url_matcher(\phpbb\extension\manager $manager, RequestCont */ function phpbb_load_url_matcher(RequestContext $context, $root_path, $php_ext) { - require($root_path . 'cache/url_matcher.' . $php_ext); + require($root_path . 'cache/' . PHPBB_ENVIRONMENT . '/url_matcher.' . $php_ext); return new phpbb_url_matcher($context); } - -/** -* Determine whether we have our dumped URL matcher -* -* The class is automatically dumped to the cache directory -* -* @param string $root_path Root path -* @param string $php_ext PHP file extension -* @return bool True if it exists, false if not -*/ -function phpbb_url_matcher_dumped($root_path, $php_ext) -{ - return file_exists($root_path . 'cache/url_matcher.' . $php_ext); -} diff --git a/phpBB/phpbb/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php index adfe87b740..d3708fe9a0 100644 --- a/phpBB/phpbb/cache/driver/file.php +++ b/phpBB/phpbb/cache/driver/file.php @@ -28,7 +28,12 @@ class file extends \phpbb\cache\driver\base function __construct($cache_dir = null) { global $phpbb_root_path; - $this->cache_dir = !is_null($cache_dir) ? $cache_dir : $phpbb_root_path . 'cache/'; + $this->cache_dir = !is_null($cache_dir) ? $cache_dir : $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/'; + + if (!is_dir($this->cache_dir)) + { + @mkdir($this->cache_dir, 0777, true); + } } /** diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index 638c13e86d..b264b0182f 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -13,16 +13,21 @@ namespace phpbb\di; +use Symfony\Component\Config\ConfigCache; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Dumper\PhpDumper; use Symfony\Component\HttpKernel\DependencyInjection\RegisterListenersPass; class container_builder { - /** @var string phpBB Root Path */ + /** + * @var string phpBB Root Path + */ protected $phpbb_root_path; - /** @var string php file extension */ + /** + * @var string php file extension + */ protected $php_ext; /** @@ -111,6 +116,11 @@ class container_builder */ protected $config_php_file; + /** + * @var string + */ + protected $cache_dir; + /** * Constructor * @@ -133,18 +143,16 @@ class container_builder public function get_container() { $container_filename = $this->get_container_filename(); - if (!defined('DEBUG_CONTAINER') && $this->dump_container && file_exists($container_filename)) + $config_cache = new ConfigCache($container_filename, defined('DEBUG')); + if ($this->dump_container && $config_cache->isFresh()) { 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)); + + $container_extensions = array(new \phpbb\di\extension\core($this->get_config_path())); if ($this->use_extensions) { @@ -178,9 +186,9 @@ class container_builder $this->container->compile(); } - if ($this->dump_container && !defined('DEBUG_CONTAINER')) + if ($this->dump_container) { - $this->dump_container($container_filename); + $this->dump_container($config_cache); } } @@ -266,6 +274,16 @@ class container_builder $this->config_path = $config_path; } + /** + * Returns the path to the container configuration (default: root_path/config) + * + * @return string + */ + protected function get_config_path() + { + return $this->config_path ?: $this->phpbb_root_path . 'config'; + } + /** * Set custom parameters to inject into the container. * @@ -276,12 +294,32 @@ class container_builder $this->custom_parameters = $custom_parameters; } + /** + * Set the path to the cache directory. + * + * @param string $cache_dir Path to the cache directory + */ + public function set_cache_dir($cache_dir) + { + $this->cache_dir = $cache_dir; + } + + /** + * Returns the path to the cache directory (default: root_path/cache/environment). + * + * @return string Path to the cache directory. + */ + protected function get_cache_dir() + { + return $this->cache_dir ?: $this->phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/'; + } + /** * Dump the container to the disk. * - * @param string $container_filename The name of the file. + * @param ConfigCache $cache The config cache */ - protected function dump_container($container_filename) + protected function dump_container($cache) { $dumper = new PhpDumper($this->container); $cached_container_dump = $dumper->dump(array( @@ -289,7 +327,7 @@ class container_builder 'base_class' => 'Symfony\\Component\\DependencyInjection\\ContainerBuilder', )); - file_put_contents($container_filename, $cached_container_dump); + $cache->write($cached_container_dump, $this->container->getResources()); } /** @@ -386,6 +424,8 @@ class container_builder ); } + $this->custom_parameters['environment'] = PHPBB_ENVIRONMENT; + foreach ($this->custom_parameters as $key => $value) { $this->container->setParameter($key, $value); @@ -400,6 +440,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->get_cache_dir() . 'container_' . $filename . '.' . $this->php_ext; } } From 74cd97e75b1dce43a05d8e15e9fbccf01e833b57 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 2 Oct 2014 00:45:22 +0200 Subject: [PATCH 21/37] [ticket/12620] Updates test environment (production => development) PHPBB3-12620 --- tests/bootstrap.php | 2 +- tests/controller/config/{production => development}/routing.yml | 0 .../vendor2/bar/config/{production => development}/routing.yml | 0 .../fixtures/config/{production => development}/environment.yml | 0 .../disabled/config/{production => development}/environment.yml | 0 .../config/{production => development}/environment.yml | 0 .../other_config/{production => development}/environment.yml | 0 tests/pagination/config/{production => development}/routing.yml | 0 8 files changed, 1 insertion(+), 1 deletion(-) rename tests/controller/config/{production => development}/routing.yml (100%) rename tests/controller/ext/vendor2/bar/config/{production => development}/routing.yml (100%) rename tests/di/fixtures/config/{production => development}/environment.yml (100%) rename tests/di/fixtures/ext/vendor/disabled/config/{production => development}/environment.yml (100%) rename tests/di/fixtures/ext/vendor/enabled-2/config/{production => development}/environment.yml (100%) rename tests/di/fixtures/other_config/{production => development}/environment.yml (100%) rename tests/pagination/config/{production => development}/routing.yml (100%) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 229a6ee82b..2fc8858585 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -12,7 +12,7 @@ */ define('IN_PHPBB', true); -define('PHPBB_ENVIRONMENT', 'production'); +define('PHPBB_ENVIRONMENT', 'development'); $phpbb_root_path = 'phpBB/'; $phpEx = 'php'; diff --git a/tests/controller/config/production/routing.yml b/tests/controller/config/development/routing.yml similarity index 100% rename from tests/controller/config/production/routing.yml rename to tests/controller/config/development/routing.yml diff --git a/tests/controller/ext/vendor2/bar/config/production/routing.yml b/tests/controller/ext/vendor2/bar/config/development/routing.yml similarity index 100% rename from tests/controller/ext/vendor2/bar/config/production/routing.yml rename to tests/controller/ext/vendor2/bar/config/development/routing.yml diff --git a/tests/di/fixtures/config/production/environment.yml b/tests/di/fixtures/config/development/environment.yml similarity index 100% rename from tests/di/fixtures/config/production/environment.yml rename to tests/di/fixtures/config/development/environment.yml diff --git a/tests/di/fixtures/ext/vendor/disabled/config/production/environment.yml b/tests/di/fixtures/ext/vendor/disabled/config/development/environment.yml similarity index 100% rename from tests/di/fixtures/ext/vendor/disabled/config/production/environment.yml rename to tests/di/fixtures/ext/vendor/disabled/config/development/environment.yml diff --git a/tests/di/fixtures/ext/vendor/enabled-2/config/production/environment.yml b/tests/di/fixtures/ext/vendor/enabled-2/config/development/environment.yml similarity index 100% rename from tests/di/fixtures/ext/vendor/enabled-2/config/production/environment.yml rename to tests/di/fixtures/ext/vendor/enabled-2/config/development/environment.yml diff --git a/tests/di/fixtures/other_config/production/environment.yml b/tests/di/fixtures/other_config/development/environment.yml similarity index 100% rename from tests/di/fixtures/other_config/production/environment.yml rename to tests/di/fixtures/other_config/development/environment.yml diff --git a/tests/pagination/config/production/routing.yml b/tests/pagination/config/development/routing.yml similarity index 100% rename from tests/pagination/config/production/routing.yml rename to tests/pagination/config/development/routing.yml From 6cbb60d13f75da6d9b6c6d60555ea119df79b5c0 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 4 Oct 2014 16:30:34 +0200 Subject: [PATCH 22/37] [ticket/12620] Adds a yaml config file PHPBB3-12620 --- phpBB/common.php | 8 --- phpBB/config/default/config.yml | 0 .../default/{ => container}/parameters.yml | 0 .../default/{ => container}/services.yml | 0 .../services_auth_providers.yml | 0 .../{ => container}/services_avatars.yml | 0 .../{ => container}/services_captcha.yml | 0 .../{ => container}/services_console.yml | 0 .../{ => container}/services_cron_tasks.yml | 0 .../default/{ => container}/services_feed.yml | 0 .../{ => container}/services_migrator.yml | 0 .../services_mimetype_guessers.yml | 0 .../services_notifications.yml | 0 .../{ => container}/services_passwords.yml | 0 .../services_profilefields.yml | 0 .../default/{ => container}/services_twig.yml | 2 +- .../config/default/{ => container}/tables.yml | 0 phpBB/config/development/config.yml | 5 ++ .../{ => container}/environment.yml | 0 .../development/container/parameters.yml | 2 + .../config/development/container/services.yml | 2 + phpBB/config/development/parameters.yml | 2 - phpBB/config/development/services.yml | 2 - phpBB/config/production/config.yml | 2 + .../{ => container}/environment.yml | 0 .../production/container/parameters.yml | 2 + .../config/production/container/services.yml | 2 + phpBB/config/production/parameters.yml | 2 - phpBB/config/production/services.yml | 2 - phpBB/phpbb/di/container_builder.php | 63 +++++++++++++------ .../di/extension/container_configuration.php | 38 +++++++++++ phpBB/phpbb/di/extension/core.php | 39 ++++++++++-- phpBB/phpbb/di/extension/ext.php | 8 +-- .../{ => container}/environment.yml | 0 .../{ => container}/environment.yml | 0 .../{ => container}/environment.yml | 0 .../default/{ => container}/environment.yml | 0 .../{ => container}/environment.yml | 0 38 files changed, 136 insertions(+), 45 deletions(-) create mode 100644 phpBB/config/default/config.yml rename phpBB/config/default/{ => container}/parameters.yml (100%) rename phpBB/config/default/{ => container}/services.yml (100%) rename phpBB/config/default/{ => container}/services_auth_providers.yml (100%) rename phpBB/config/default/{ => container}/services_avatars.yml (100%) rename phpBB/config/default/{ => container}/services_captcha.yml (100%) rename phpBB/config/default/{ => container}/services_console.yml (100%) rename phpBB/config/default/{ => container}/services_cron_tasks.yml (100%) rename phpBB/config/default/{ => container}/services_feed.yml (100%) rename phpBB/config/default/{ => container}/services_migrator.yml (100%) rename phpBB/config/default/{ => container}/services_mimetype_guessers.yml (100%) rename phpBB/config/default/{ => container}/services_notifications.yml (100%) rename phpBB/config/default/{ => container}/services_passwords.yml (100%) rename phpBB/config/default/{ => container}/services_profilefields.yml (100%) rename phpBB/config/default/{ => container}/services_twig.yml (93%) rename phpBB/config/default/{ => container}/tables.yml (100%) create mode 100644 phpBB/config/development/config.yml rename phpBB/config/development/{ => container}/environment.yml (100%) create mode 100644 phpBB/config/development/container/parameters.yml create mode 100644 phpBB/config/development/container/services.yml delete mode 100644 phpBB/config/development/parameters.yml delete mode 100644 phpBB/config/development/services.yml create mode 100644 phpBB/config/production/config.yml rename phpBB/config/production/{ => container}/environment.yml (100%) create mode 100644 phpBB/config/production/container/parameters.yml create mode 100644 phpBB/config/production/container/services.yml delete mode 100644 phpBB/config/production/parameters.yml delete mode 100644 phpBB/config/production/services.yml create mode 100644 phpBB/phpbb/di/extension/container_configuration.php rename tests/di/fixtures/config/development/{ => container}/environment.yml (100%) rename tests/di/fixtures/ext/vendor/disabled/config/development/{ => container}/environment.yml (100%) rename tests/di/fixtures/ext/vendor/enabled-2/config/development/{ => container}/environment.yml (100%) rename tests/di/fixtures/ext/vendor/enabled/config/default/{ => container}/environment.yml (100%) rename tests/di/fixtures/other_config/development/{ => container}/environment.yml (100%) diff --git a/phpBB/common.php b/phpBB/common.php index 85568ab10e..2fa0c46b22 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -96,14 +96,6 @@ set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handle $phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx); $phpbb_class_loader_ext->register(); -if (PHPBB_ENVIRONMENT == 'debug' && !class_exists('Goutte\Client', true)) -{ - trigger_error( - 'Composer development dependencies have not been set up for the development environment yet, run ' . - "'php ../composer.phar install --dev' from the phpBB directory to do so.", - E_USER_ERROR - ); -} phpbb_load_extensions_autoloaders($phpbb_root_path); // Set up container diff --git a/phpBB/config/default/config.yml b/phpBB/config/default/config.yml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/phpBB/config/default/parameters.yml b/phpBB/config/default/container/parameters.yml similarity index 100% rename from phpBB/config/default/parameters.yml rename to phpBB/config/default/container/parameters.yml diff --git a/phpBB/config/default/services.yml b/phpBB/config/default/container/services.yml similarity index 100% rename from phpBB/config/default/services.yml rename to phpBB/config/default/container/services.yml diff --git a/phpBB/config/default/services_auth_providers.yml b/phpBB/config/default/container/services_auth_providers.yml similarity index 100% rename from phpBB/config/default/services_auth_providers.yml rename to phpBB/config/default/container/services_auth_providers.yml diff --git a/phpBB/config/default/services_avatars.yml b/phpBB/config/default/container/services_avatars.yml similarity index 100% rename from phpBB/config/default/services_avatars.yml rename to phpBB/config/default/container/services_avatars.yml diff --git a/phpBB/config/default/services_captcha.yml b/phpBB/config/default/container/services_captcha.yml similarity index 100% rename from phpBB/config/default/services_captcha.yml rename to phpBB/config/default/container/services_captcha.yml diff --git a/phpBB/config/default/services_console.yml b/phpBB/config/default/container/services_console.yml similarity index 100% rename from phpBB/config/default/services_console.yml rename to phpBB/config/default/container/services_console.yml diff --git a/phpBB/config/default/services_cron_tasks.yml b/phpBB/config/default/container/services_cron_tasks.yml similarity index 100% rename from phpBB/config/default/services_cron_tasks.yml rename to phpBB/config/default/container/services_cron_tasks.yml diff --git a/phpBB/config/default/services_feed.yml b/phpBB/config/default/container/services_feed.yml similarity index 100% rename from phpBB/config/default/services_feed.yml rename to phpBB/config/default/container/services_feed.yml diff --git a/phpBB/config/default/services_migrator.yml b/phpBB/config/default/container/services_migrator.yml similarity index 100% rename from phpBB/config/default/services_migrator.yml rename to phpBB/config/default/container/services_migrator.yml diff --git a/phpBB/config/default/services_mimetype_guessers.yml b/phpBB/config/default/container/services_mimetype_guessers.yml similarity index 100% rename from phpBB/config/default/services_mimetype_guessers.yml rename to phpBB/config/default/container/services_mimetype_guessers.yml diff --git a/phpBB/config/default/services_notifications.yml b/phpBB/config/default/container/services_notifications.yml similarity index 100% rename from phpBB/config/default/services_notifications.yml rename to phpBB/config/default/container/services_notifications.yml diff --git a/phpBB/config/default/services_passwords.yml b/phpBB/config/default/container/services_passwords.yml similarity index 100% rename from phpBB/config/default/services_passwords.yml rename to phpBB/config/default/container/services_passwords.yml diff --git a/phpBB/config/default/services_profilefields.yml b/phpBB/config/default/container/services_profilefields.yml similarity index 100% rename from phpBB/config/default/services_profilefields.yml rename to phpBB/config/default/container/services_profilefields.yml diff --git a/phpBB/config/default/services_twig.yml b/phpBB/config/default/container/services_twig.yml similarity index 93% rename from phpBB/config/default/services_twig.yml rename to phpBB/config/default/container/services_twig.yml index 06ce5bc15c..fc5f9ba6a1 100644 --- a/phpBB/config/default/services_twig.yml +++ b/phpBB/config/default/container/services_twig.yml @@ -1,5 +1,5 @@ parameters: - core.template.cache_path: %core.root_path%cache/%environment%/twig/ + core.template.cache_path: %core.root_path%cache/%core.environment%/twig/ services: template.twig.environment: diff --git a/phpBB/config/default/tables.yml b/phpBB/config/default/container/tables.yml similarity index 100% rename from phpBB/config/default/tables.yml rename to phpBB/config/default/container/tables.yml diff --git a/phpBB/config/development/config.yml b/phpBB/config/development/config.yml new file mode 100644 index 0000000000..1c17b08931 --- /dev/null +++ b/phpBB/config/development/config.yml @@ -0,0 +1,5 @@ +imports: + - { resource: ../default/config.yml } + +core: + require_dev_dependencies: true diff --git a/phpBB/config/development/environment.yml b/phpBB/config/development/container/environment.yml similarity index 100% rename from phpBB/config/development/environment.yml rename to phpBB/config/development/container/environment.yml diff --git a/phpBB/config/development/container/parameters.yml b/phpBB/config/development/container/parameters.yml new file mode 100644 index 0000000000..0447646806 --- /dev/null +++ b/phpBB/config/development/container/parameters.yml @@ -0,0 +1,2 @@ +imports: + - { resource: ../../default/container/parameters.yml } diff --git a/phpBB/config/development/container/services.yml b/phpBB/config/development/container/services.yml new file mode 100644 index 0000000000..b302f0f966 --- /dev/null +++ b/phpBB/config/development/container/services.yml @@ -0,0 +1,2 @@ +imports: + - { resource: ../../default/container/services.yml } diff --git a/phpBB/config/development/parameters.yml b/phpBB/config/development/parameters.yml deleted file mode 100644 index 02743729f9..0000000000 --- a/phpBB/config/development/parameters.yml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: ../default/parameters.yml } diff --git a/phpBB/config/development/services.yml b/phpBB/config/development/services.yml deleted file mode 100644 index 6342885067..0000000000 --- a/phpBB/config/development/services.yml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: ../default/services.yml } diff --git a/phpBB/config/production/config.yml b/phpBB/config/production/config.yml new file mode 100644 index 0000000000..979dbbcdd9 --- /dev/null +++ b/phpBB/config/production/config.yml @@ -0,0 +1,2 @@ +imports: + - { resource: ../default/config.yml } diff --git a/phpBB/config/production/environment.yml b/phpBB/config/production/container/environment.yml similarity index 100% rename from phpBB/config/production/environment.yml rename to phpBB/config/production/container/environment.yml diff --git a/phpBB/config/production/container/parameters.yml b/phpBB/config/production/container/parameters.yml new file mode 100644 index 0000000000..0447646806 --- /dev/null +++ b/phpBB/config/production/container/parameters.yml @@ -0,0 +1,2 @@ +imports: + - { resource: ../../default/container/parameters.yml } diff --git a/phpBB/config/production/container/services.yml b/phpBB/config/production/container/services.yml new file mode 100644 index 0000000000..b302f0f966 --- /dev/null +++ b/phpBB/config/production/container/services.yml @@ -0,0 +1,2 @@ +imports: + - { resource: ../../default/container/services.yml } diff --git a/phpBB/config/production/parameters.yml b/phpBB/config/production/parameters.yml deleted file mode 100644 index 02743729f9..0000000000 --- a/phpBB/config/production/parameters.yml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: ../default/parameters.yml } diff --git a/phpBB/config/production/services.yml b/phpBB/config/production/services.yml deleted file mode 100644 index 6342885067..0000000000 --- a/phpBB/config/production/services.yml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: ../default/services.yml } diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index b264b0182f..45dbaaf303 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -14,9 +14,13 @@ namespace phpbb\di; use Symfony\Component\Config\ConfigCache; +use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Dumper\PhpDumper; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\HttpKernel\DependencyInjection\RegisterListenersPass; +use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; class container_builder { @@ -151,7 +155,6 @@ class container_builder } else { - $container_extensions = array(new \phpbb\di\extension\core($this->get_config_path())); if ($this->use_extensions) @@ -179,7 +182,8 @@ class container_builder } } - $this->inject_custom_parameters(); + $loader = new YamlFileLoader($this->container, new FileLocator(phpbb_realpath($this->get_config_path()))); + $loader->load(PHPBB_ENVIRONMENT . '/config.yml'); if ($this->compile_container) { @@ -400,36 +404,59 @@ class container_builder */ protected function create_container(array $extensions) { - $container = new ContainerBuilder(); + $container = new ContainerBuilder(new ParameterBag($this->get_core_parameters())); + + $extensions_alias = array(); foreach ($extensions as $extension) { $container->registerExtension($extension); - $container->loadFromExtension($extension->getAlias()); + $extensions_alias[] = $extension->getAlias(); + //$container->loadFromExtension($extension->getAlias()); } + $container->getCompilerPassConfig()->setMergePass(new MergeExtensionConfigurationPass($extensions_alias)); + return $container; } /** - * Inject the customs parameters into the container - */ - protected function inject_custom_parameters() + * Returns the core parameters. + * + * @return array An array of core parameters + */ + protected function get_core_parameters() { - if ($this->custom_parameters === null) + return array_merge( + array( + 'core.root_path' => $this->phpbb_root_path, + 'core.php_ext' => $this->php_ext, + 'core.environment' => PHPBB_ENVIRONMENT, + 'core.debug' => DEBUG, + ), + $this->get_env_parameters() + ); + } + + /** + * Gets the environment parameters. + * + * Only the parameters starting with "PHPBB__" are considered. + * + * @return array An array of parameters + */ + protected function get_env_parameters() + { + $parameters = array(); + foreach ($_SERVER as $key => $value) { - $this->custom_parameters = array( - 'core.root_path' => $this->phpbb_root_path, - 'core.php_ext' => $this->php_ext, - ); + if (0 === strpos($key, 'PHPBB__')) + { + $parameters[strtolower(str_replace('__', '.', substr($key, 9)))] = $value; + } } - $this->custom_parameters['environment'] = PHPBB_ENVIRONMENT; - - foreach ($this->custom_parameters as $key => $value) - { - $this->container->setParameter($key, $value); - } + return $parameters; } /** diff --git a/phpBB/phpbb/di/extension/container_configuration.php b/phpBB/phpbb/di/extension/container_configuration.php new file mode 100644 index 0000000000..1f1c077472 --- /dev/null +++ b/phpBB/phpbb/di/extension/container_configuration.php @@ -0,0 +1,38 @@ + +* @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\Config\Definition\Builder\TreeBuilder; +use Symfony\Component\Config\Definition\ConfigurationInterface; + +class container_configuration implements ConfigurationInterface +{ + + /** + * Generates the configuration tree builder. + * + * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder + */ + public function getConfigTreeBuilder() + { + $treeBuilder = new TreeBuilder(); + $rootNode = $treeBuilder->root('core'); + $rootNode + ->children() + ->booleanNode('require_dev_dependencies')->defaultValue(false)->end() + ->end() + ; + return $treeBuilder; + } +} diff --git a/phpBB/phpbb/di/extension/core.php b/phpBB/phpbb/di/extension/core.php index 7787602aba..62fcf46ad5 100644 --- a/phpBB/phpbb/di/extension/core.php +++ b/phpBB/phpbb/di/extension/core.php @@ -13,10 +13,11 @@ namespace phpbb\di\extension; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\HttpKernel\DependencyInjection\Extension; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\Config\FileLocator; +use Symfony\Component\Config\Resource\FileResource; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; +use Symfony\Component\HttpKernel\DependencyInjection\Extension; /** * Container core extension @@ -42,15 +43,41 @@ class core extends Extension /** * Loads a specific configuration. * - * @param array $config An array of configuration values + * @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 $config, ContainerBuilder $container) + public function load(array $configs, ContainerBuilder $container) { $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->config_path))); - $loader->load(PHPBB_ENVIRONMENT . '/environment.yml'); + $loader->load(PHPBB_ENVIRONMENT . '/container/environment.yml'); + + $config = $this->getConfiguration($configs, $container); + $config = $this->processConfiguration($config, $configs); + + if ($config['require_dev_dependencies']) + { + if (!class_exists('Goutte\Client', true)) + { + trigger_error( + 'Composer development dependencies have not been set up for the ' . $container->getParameter('core.environment') . ' environment yet, run ' . + "'php ../composer.phar install --dev' from the phpBB directory to do so.", + E_USER_ERROR + ); + } + } + } + + /** + * {@inheritdoc} + */ + public function getConfiguration(array $config, ContainerBuilder $container) + { + $r = new \ReflectionClass('\phpbb\di\extension\container_configuration'); + $container->addResource(new FileResource($r->getFileName())); + + return new container_configuration(); } /** diff --git a/phpBB/phpbb/di/extension/ext.php b/phpBB/phpbb/di/extension/ext.php index 330303ca0c..021e862118 100644 --- a/phpBB/phpbb/di/extension/ext.php +++ b/phpBB/phpbb/di/extension/ext.php @@ -48,16 +48,16 @@ class ext extends Extension $services_directory = false; $services_file = false; - if (file_exists($path . 'config/' . PHPBB_ENVIRONMENT . '/environment.yml')) + if (file_exists($path . 'config/' . PHPBB_ENVIRONMENT . '/container/environment.yml')) { - $services_directory = $path . 'config/' . PHPBB_ENVIRONMENT; + $services_directory = $path . 'config/' . PHPBB_ENVIRONMENT . '/container/'; $services_file = 'environment.yml'; } else if (!is_dir($path . 'config/' . PHPBB_ENVIRONMENT)) { - if (file_exists($path . 'config/default/environment.yml')) + if (file_exists($path . 'config/default/container/environment.yml')) { - $services_directory = $path . 'config/default'; + $services_directory = $path . 'config/default/container/'; $services_file = 'environment.yml'; } else if (!is_dir($path . 'config/default') && file_exists($path . '/config/services.yml')) diff --git a/tests/di/fixtures/config/development/environment.yml b/tests/di/fixtures/config/development/container/environment.yml similarity index 100% rename from tests/di/fixtures/config/development/environment.yml rename to tests/di/fixtures/config/development/container/environment.yml diff --git a/tests/di/fixtures/ext/vendor/disabled/config/development/environment.yml b/tests/di/fixtures/ext/vendor/disabled/config/development/container/environment.yml similarity index 100% rename from tests/di/fixtures/ext/vendor/disabled/config/development/environment.yml rename to tests/di/fixtures/ext/vendor/disabled/config/development/container/environment.yml diff --git a/tests/di/fixtures/ext/vendor/enabled-2/config/development/environment.yml b/tests/di/fixtures/ext/vendor/enabled-2/config/development/container/environment.yml similarity index 100% rename from tests/di/fixtures/ext/vendor/enabled-2/config/development/environment.yml rename to tests/di/fixtures/ext/vendor/enabled-2/config/development/container/environment.yml diff --git a/tests/di/fixtures/ext/vendor/enabled/config/default/environment.yml b/tests/di/fixtures/ext/vendor/enabled/config/default/container/environment.yml similarity index 100% rename from tests/di/fixtures/ext/vendor/enabled/config/default/environment.yml rename to tests/di/fixtures/ext/vendor/enabled/config/default/container/environment.yml diff --git a/tests/di/fixtures/other_config/development/environment.yml b/tests/di/fixtures/other_config/development/container/environment.yml similarity index 100% rename from tests/di/fixtures/other_config/development/environment.yml rename to tests/di/fixtures/other_config/development/container/environment.yml From 3a167aa0c3eaec6c4b9d322460480786234e0419 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 4 Oct 2014 17:30:10 +0200 Subject: [PATCH 23/37] [ticket/12620] Creates one di extension per phpBB extension PHPBB3-12620 --- phpBB/phpbb/di/container_builder.php | 12 +- phpBB/phpbb/di/extension/ext.php | 89 ------------ phpBB/phpbb/extension/di/extension_base.php | 137 ++++++++++++++++++ .../di/fixtures/config/development/config.yml | 2 + 4 files changed, 150 insertions(+), 90 deletions(-) delete mode 100644 phpBB/phpbb/di/extension/ext.php create mode 100644 phpBB/phpbb/extension/di/extension_base.php create mode 100644 tests/di/fixtures/config/development/config.yml diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index 45dbaaf303..5ad9336695 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -160,7 +160,17 @@ class container_builder if ($this->use_extensions) { $installed_exts = $this->get_installed_extensions(); - $container_extensions[] = new \phpbb\di\extension\ext($installed_exts); + foreach ($installed_exts as $ext_name => $path) + { + $extension_class = '\\' . str_replace('/', '\\', $ext_name) . '\\di\extension'; + + if (!class_exists($extension_class)) + { + $extension_class = '\phpbb\extension\di\extension_base'; + } + + $container_extensions[] = new $extension_class($ext_name, $path); + } } if ($this->inject_config) diff --git a/phpBB/phpbb/di/extension/ext.php b/phpBB/phpbb/di/extension/ext.php deleted file mode 100644 index 021e862118..0000000000 --- a/phpBB/phpbb/di/extension/ext.php +++ /dev/null @@ -1,89 +0,0 @@ - -* @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; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -use Symfony\Component\Config\FileLocator; - -/** -* Container ext extension -*/ -class ext extends Extension -{ - protected $paths = array(); - - public function __construct($enabled_extensions) - { - foreach ($enabled_extensions as $ext => $path) - { - $this->paths[] = $path; - } - } - - /** - * Loads a specific configuration. - * - * @param array $config 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 $config, ContainerBuilder $container) - { - foreach ($this->paths as $path) - { - $services_directory = false; - $services_file = false; - - if (file_exists($path . 'config/' . PHPBB_ENVIRONMENT . '/container/environment.yml')) - { - $services_directory = $path . 'config/' . PHPBB_ENVIRONMENT . '/container/'; - $services_file = 'environment.yml'; - } - else if (!is_dir($path . 'config/' . PHPBB_ENVIRONMENT)) - { - if (file_exists($path . 'config/default/container/environment.yml')) - { - $services_directory = $path . 'config/default/container/'; - $services_file = 'environment.yml'; - } - else if (!is_dir($path . 'config/default') && file_exists($path . '/config/services.yml')) - { - $services_directory = $path . 'config'; - $services_file = 'services.yml'; - } - } - - if ($services_directory && $services_file) - { - $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($services_directory))); - $loader->load($services_file); - } - } - } - - /** - * 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 'ext'; - } -} diff --git a/phpBB/phpbb/extension/di/extension_base.php b/phpBB/phpbb/extension/di/extension_base.php new file mode 100644 index 0000000000..74026bd53a --- /dev/null +++ b/phpBB/phpbb/extension/di/extension_base.php @@ -0,0 +1,137 @@ + +* @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\extension\di; + +use Symfony\Component\Config\FileLocator; +use Symfony\Component\Config\Resource\FileResource; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; +use Symfony\Component\HttpKernel\DependencyInjection\Extension; + +/** +* Container core extension +*/ +class extension_base extends Extension +{ + /** + * Name of the extension (vendor/name) + * + * @var string + */ + protected $extension_name; + + /** + * Path to the extension. + * + * @var string + */ + protected $ext_path; + + /** + * Constructor + * + * @param string $extension_name Name of the extension (vendor/name) + * @param string $ext_path Path to the extension + */ + public function __construct($extension_name, $ext_path) + { + $this->extension_name = $extension_name; + $this->ext_path = $ext_path; + } + + /** + * 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) + { + $this->load_services($container); + } + + /** + * Loads the services.yml file. + * + * @param ContainerBuilder $container A ContainerBuilder instance + */ + protected function load_services(ContainerBuilder $container) + { + $services_directory = false; + $services_file = false; + + if (file_exists($this->ext_path . 'config/' . $container->getParameter('core.environment') . '/container/environment.yml')) + { + $services_directory = $this->ext_path . 'config/' . $container->getParameter('core.environment') . '/container/'; + $services_file = 'environment.yml'; + } + else if (!is_dir($this->ext_path . 'config/' . $container->getParameter('core.environment'))) + { + if (file_exists($this->ext_path . 'config/default/container/environment.yml')) + { + $services_directory = $this->ext_path . 'config/default/container/'; + $services_file = 'environment.yml'; + } + else if (!is_dir($this->ext_path . 'config/default') && file_exists($this->ext_path . '/config/services.yml')) + { + $services_directory = $this->ext_path . 'config'; + $services_file = 'services.yml'; + } + } + + if ($services_directory && $services_file) + { + $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($services_directory))); + $loader->load($services_file); + } + } + + /** + * {@inheritdoc} + */ + public function getConfiguration(array $config, ContainerBuilder $container) + { + $reflected = new \ReflectionClass($this); + $namespace = $reflected->getNamespaceName(); + + $class = $namespace . '\\di\configuration'; + if (class_exists($class)) + { + $r = new \ReflectionClass($class); + $container->addResource(new FileResource($r->getFileName())); + + if (!method_exists($class, '__construct')) + { + $configuration = new $class(); + + return $configuration; + } + } + + } + + /** + * 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 str_replace('/', '_', $this->extension_name); + } +} diff --git a/tests/di/fixtures/config/development/config.yml b/tests/di/fixtures/config/development/config.yml new file mode 100644 index 0000000000..fcfa84f68b --- /dev/null +++ b/tests/di/fixtures/config/development/config.yml @@ -0,0 +1,2 @@ +core: + require_dev_dependencies: true From 0b61e3540de353f2bf0a6904a87727e4efe9c5fa Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 4 Oct 2014 17:47:36 +0200 Subject: [PATCH 24/37] [ticket/12620] Fix tests PHPBB3-12620 --- phpBB/phpbb/di/container_builder.php | 16 ++++++++++++++++ tests/di/create_container_test.php | 1 - .../fixtures/other_config/development/config.yml | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/di/fixtures/other_config/development/config.yml diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index 5ad9336695..6216dad978 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -195,6 +195,8 @@ class container_builder $loader = new YamlFileLoader($this->container, new FileLocator(phpbb_realpath($this->get_config_path()))); $loader->load(PHPBB_ENVIRONMENT . '/config.yml'); + $this->inject_custom_parameters(); + if ($this->compile_container) { $this->container->compile(); @@ -430,6 +432,20 @@ class container_builder return $container; } + /** + * Inject the customs parameters into the container + */ + protected function inject_custom_parameters() + { + if ($this->custom_parameters !== null) + { + foreach ($this->custom_parameters as $key => $value) + { + $this->container->setParameter($key, $value); + } + } + } + /** * Returns the core parameters. * diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index ec9828debb..4e47751999 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -146,7 +146,6 @@ namespace $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); $this->assertTrue($container->hasParameter('my_parameter')); - $this->assertFalse($container->hasParameter('core.root_path')); } } } diff --git a/tests/di/fixtures/other_config/development/config.yml b/tests/di/fixtures/other_config/development/config.yml new file mode 100644 index 0000000000..fcfa84f68b --- /dev/null +++ b/tests/di/fixtures/other_config/development/config.yml @@ -0,0 +1,2 @@ +core: + require_dev_dependencies: true From c98efc53a80150b6f9189c9b194855c748e9b03d Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 7 Nov 2014 14:27:00 +0100 Subject: [PATCH 25/37] [ticket/12620] Fix rebase (move config file to the right directory) PHPBB3-12620 --- .../default/{ => container}/services_auth.yml | 0 .../container/services_auth_providers.yml | 86 ---- .../{ => container}/services_avatar.yml | 0 .../default/container/services_avatars.yml | 60 --- .../{ => container}/services_content.yml | 0 .../default/{ => container}/services_cron.yml | 0 .../default/container/services_cron_tasks.yml | 125 ------ .../default/{ => container}/services_db.yml | 0 .../{ => container}/services_event.yml | 0 .../services_mimetype_guesser.yml | 0 .../container/services_mimetype_guessers.yml | 43 -- .../{ => container}/services_notification.yml | 0 .../container/services_notifications.yml | 368 ------------------ .../{ => container}/services_password.yml | 0 .../default/container/services_passwords.yml | 128 ------ .../{ => container}/services_profilefield.yml | 0 .../container/services_profilefields.yml | 101 ----- .../default/{ => container}/services_user.yml | 0 18 files changed, 911 deletions(-) rename phpBB/config/default/{ => container}/services_auth.yml (100%) delete mode 100644 phpBB/config/default/container/services_auth_providers.yml rename phpBB/config/default/{ => container}/services_avatar.yml (100%) delete mode 100644 phpBB/config/default/container/services_avatars.yml rename phpBB/config/default/{ => container}/services_content.yml (100%) rename phpBB/config/default/{ => container}/services_cron.yml (100%) delete mode 100644 phpBB/config/default/container/services_cron_tasks.yml rename phpBB/config/default/{ => container}/services_db.yml (100%) rename phpBB/config/default/{ => container}/services_event.yml (100%) rename phpBB/config/default/{ => container}/services_mimetype_guesser.yml (100%) delete mode 100644 phpBB/config/default/container/services_mimetype_guessers.yml rename phpBB/config/default/{ => container}/services_notification.yml (100%) delete mode 100644 phpBB/config/default/container/services_notifications.yml rename phpBB/config/default/{ => container}/services_password.yml (100%) delete mode 100644 phpBB/config/default/container/services_passwords.yml rename phpBB/config/default/{ => container}/services_profilefield.yml (100%) delete mode 100644 phpBB/config/default/container/services_profilefields.yml rename phpBB/config/default/{ => container}/services_user.yml (100%) diff --git a/phpBB/config/default/services_auth.yml b/phpBB/config/default/container/services_auth.yml similarity index 100% rename from phpBB/config/default/services_auth.yml rename to phpBB/config/default/container/services_auth.yml diff --git a/phpBB/config/default/container/services_auth_providers.yml b/phpBB/config/default/container/services_auth_providers.yml deleted file mode 100644 index 89303a684a..0000000000 --- a/phpBB/config/default/container/services_auth_providers.yml +++ /dev/null @@ -1,86 +0,0 @@ -services: - auth.provider_collection: - class: phpbb\auth\provider_collection - arguments: - - @service_container - - @config - tags: - - { name: service_collection, tag: auth.provider } - auth.provider.db: - class: phpbb\auth\provider\db - arguments: - - @dbal.conn - - @config - - @passwords.manager - - @request - - @user - - @service_container - - %core.root_path% - - %core.php_ext% - tags: - - { name: auth.provider } - auth.provider.apache: - class: phpbb\auth\provider\apache - arguments: - - @dbal.conn - - @config - - @passwords.manager - - @request - - @user - - %core.root_path% - - %core.php_ext% - tags: - - { name: auth.provider } - auth.provider.ldap: - class: phpbb\auth\provider\ldap - arguments: - - @dbal.conn - - @config - - @passwords.manager - - @user - tags: - - { name: auth.provider } - auth.provider.oauth: - class: phpbb\auth\provider\oauth\oauth - arguments: - - @dbal.conn - - @config - - @passwords.manager - - @request - - @user - - %tables.auth_provider_oauth_token_storage% - - %tables.auth_provider_oauth_account_assoc% - - @auth.provider.oauth.service_collection - - %tables.users% - - @service_container - - %core.root_path% - - %core.php_ext% - tags: - - { name: auth.provider } - auth.provider.oauth.service_collection: - class: phpbb\di\service_collection - arguments: - - @service_container - tags: - - { name: service_collection, tag: auth.provider.oauth.service } - auth.provider.oauth.service.bitly: - class: phpbb\auth\provider\oauth\service\bitly - arguments: - - @config - - @request - tags: - - { name: auth.provider.oauth.service } - auth.provider.oauth.service.facebook: - class: phpbb\auth\provider\oauth\service\facebook - arguments: - - @config - - @request - tags: - - { name: auth.provider.oauth.service } - auth.provider.oauth.service.google: - class: phpbb\auth\provider\oauth\service\google - arguments: - - @config - - @request - tags: - - { name: auth.provider.oauth.service } diff --git a/phpBB/config/default/services_avatar.yml b/phpBB/config/default/container/services_avatar.yml similarity index 100% rename from phpBB/config/default/services_avatar.yml rename to phpBB/config/default/container/services_avatar.yml diff --git a/phpBB/config/default/container/services_avatars.yml b/phpBB/config/default/container/services_avatars.yml deleted file mode 100644 index 8e5b1fdbfe..0000000000 --- a/phpBB/config/default/container/services_avatars.yml +++ /dev/null @@ -1,60 +0,0 @@ -services: - avatar.driver.gravatar: - class: phpbb\avatar\driver\gravatar - arguments: - - @config - - %core.root_path% - - %core.php_ext% - - @path_helper - - @cache.driver - calls: - - [set_name, [avatar.driver.gravatar]] - tags: - - { name: avatar.driver } - - avatar.driver.local: - class: phpbb\avatar\driver\local - arguments: - - @config - - %core.root_path% - - %core.php_ext% - - @path_helper - - @cache.driver - calls: - - [set_name, [avatar.driver.local]] - tags: - - { name: avatar.driver } - - avatar.driver.remote: - class: phpbb\avatar\driver\remote - arguments: - - @config - - %core.root_path% - - %core.php_ext% - - @path_helper - - @cache.driver - calls: - - [set_name, [avatar.driver.remote]] - tags: - - { name: avatar.driver } - - avatar.driver.upload: - class: phpbb\avatar\driver\upload - arguments: - - @config - - %core.root_path% - - %core.php_ext% - - @path_helper - - @mimetype.guesser - - @cache.driver - calls: - - [set_name, [avatar.driver.upload]] - tags: - - { name: avatar.driver } - - avatar.driver_collection: - class: phpbb\di\service_collection - arguments: - - @service_container - tags: - - { name: service_collection, tag: avatar.driver } diff --git a/phpBB/config/default/services_content.yml b/phpBB/config/default/container/services_content.yml similarity index 100% rename from phpBB/config/default/services_content.yml rename to phpBB/config/default/container/services_content.yml diff --git a/phpBB/config/default/services_cron.yml b/phpBB/config/default/container/services_cron.yml similarity index 100% rename from phpBB/config/default/services_cron.yml rename to phpBB/config/default/container/services_cron.yml diff --git a/phpBB/config/default/container/services_cron_tasks.yml b/phpBB/config/default/container/services_cron_tasks.yml deleted file mode 100644 index acf9a48bf9..0000000000 --- a/phpBB/config/default/container/services_cron_tasks.yml +++ /dev/null @@ -1,125 +0,0 @@ -services: - cron.task.core.prune_all_forums: - class: phpbb\cron\task\core\prune_all_forums - arguments: - - %core.root_path% - - %core.php_ext% - - @config - - @dbal.conn - calls: - - [set_name, [cron.task.core.prune_all_forums]] - tags: - - { name: cron.task } - - cron.task.core.prune_forum: - class: phpbb\cron\task\core\prune_forum - arguments: - - %core.root_path% - - %core.php_ext% - - @config - - @dbal.conn - calls: - - [set_name, [cron.task.core.prune_forum]] - tags: - - { name: cron.task } - - cron.task.core.prune_shadow_topics: - class: phpbb\cron\task\core\prune_shadow_topics - arguments: - - %core.root_path% - - %core.php_ext% - - @config - - @dbal.conn - - @log - - @user - calls: - - [set_name, [cron.task.core.prune_shadow_topics]] - tags: - - { name: cron.task } - - cron.task.core.prune_notifications: - class: phpbb\cron\task\core\prune_notifications - arguments: - - @config - - @notification_manager - calls: - - [set_name, [cron.task.core.prune_notifications]] - tags: - - { name: cron.task } - - cron.task.core.queue: - class: phpbb\cron\task\core\queue - arguments: - - %core.root_path% - - %core.php_ext% - - @config - calls: - - [set_name, [cron.task.core.queue]] - tags: - - { name: cron.task } - - cron.task.core.tidy_cache: - class: phpbb\cron\task\core\tidy_cache - arguments: - - @config - - @cache.driver - calls: - - [set_name, [cron.task.core.tidy_cache]] - tags: - - { name: cron.task } - - cron.task.core.tidy_database: - class: phpbb\cron\task\core\tidy_database - arguments: - - %core.root_path% - - %core.php_ext% - - @config - calls: - - [set_name, [cron.task.core.tidy_database]] - tags: - - { name: cron.task } - - cron.task.core.tidy_plupload: - class: phpbb\cron\task\core\tidy_plupload - arguments: - - %core.root_path% - - @config - calls: - - [set_name, [cron.task.core.tidy_plupload]] - tags: - - { name: cron.task } - - cron.task.core.tidy_search: - class: phpbb\cron\task\core\tidy_search - arguments: - - %core.root_path% - - %core.php_ext% - - @auth - - @config - - @dbal.conn - - @user - calls: - - [set_name, [cron.task.core.tidy_search]] - tags: - - { name: cron.task } - - cron.task.core.tidy_sessions: - class: phpbb\cron\task\core\tidy_sessions - arguments: - - @config - - @user - calls: - - [set_name, [cron.task.core.tidy_sessions]] - tags: - - { name: cron.task } - - cron.task.core.tidy_warnings: - class: phpbb\cron\task\core\tidy_warnings - arguments: - - %core.root_path% - - %core.php_ext% - - @config - calls: - - [set_name, [cron.task.core.tidy_warnings]] - tags: - - { name: cron.task } diff --git a/phpBB/config/default/services_db.yml b/phpBB/config/default/container/services_db.yml similarity index 100% rename from phpBB/config/default/services_db.yml rename to phpBB/config/default/container/services_db.yml diff --git a/phpBB/config/default/services_event.yml b/phpBB/config/default/container/services_event.yml similarity index 100% rename from phpBB/config/default/services_event.yml rename to phpBB/config/default/container/services_event.yml diff --git a/phpBB/config/default/services_mimetype_guesser.yml b/phpBB/config/default/container/services_mimetype_guesser.yml similarity index 100% rename from phpBB/config/default/services_mimetype_guesser.yml rename to phpBB/config/default/container/services_mimetype_guesser.yml diff --git a/phpBB/config/default/container/services_mimetype_guessers.yml b/phpBB/config/default/container/services_mimetype_guessers.yml deleted file mode 100644 index 0115146deb..0000000000 --- a/phpBB/config/default/container/services_mimetype_guessers.yml +++ /dev/null @@ -1,43 +0,0 @@ -parameters: - mimetype.guesser.priority.lowest: -2 - mimetype.guesser.priority.low: -1 - mimetype.guesser.priority.default: 0 - mimetype.guesser.priority.high: 1 - mimetype.guesser.priority.highest: 2 - -services: - mimetype.fileinfo_mimetype_guesser: - class: Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser - tags: - - { name: mimetype.guessers } - - mimetype.filebinary_mimetype_guesser: - class: Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser - tags: - - { name: mimetype.guessers } - - mimetype.content_guesser: - class: phpbb\mimetype\content_guesser - calls: - - [set_priority, [%mimetype.guesser.priority.low%]] - tags: - - { name: mimetype.guessers } - - mimetype.extension_guesser: - class: phpbb\mimetype\extension_guesser - calls: - - [set_priority, [%mimetype.guesser.priority.lowest%]] - tags: - - { name: mimetype.guessers } - - mimetype.guesser_collection: - class: phpbb\di\service_collection - arguments: - - @service_container - tags: - - { name: service_collection, tag: mimetype.guessers } - - mimetype.guesser: - class: phpbb\mimetype\guesser - arguments: - - @mimetype.guesser_collection diff --git a/phpBB/config/default/services_notification.yml b/phpBB/config/default/container/services_notification.yml similarity index 100% rename from phpBB/config/default/services_notification.yml rename to phpBB/config/default/container/services_notification.yml diff --git a/phpBB/config/default/container/services_notifications.yml b/phpBB/config/default/container/services_notifications.yml deleted file mode 100644 index 5675e76a99..0000000000 --- a/phpBB/config/default/container/services_notifications.yml +++ /dev/null @@ -1,368 +0,0 @@ -services: - notification.type_collection: - class: phpbb\di\service_collection - arguments: - - @service_container - tags: - - { name: service_collection, tag: notification.type } - - notification.method_collection: - class: phpbb\di\service_collection - arguments: - - @service_container - tags: - - { name: service_collection, tag: notification.method } - - notification.type.approve_post: - class: phpbb\notification\type\approve_post - scope: prototype # scope MUST be prototype for this to work! # scope MUST be prototype for this to work! - arguments: - - @user_loader - - @dbal.conn - - @cache.driver - - @user - - @auth - - @config - - %core.root_path% - - %core.php_ext% - - %tables.notification_types% - - %tables.notifications% - - %tables.user_notifications% - tags: - - { name: notification.type } - - notification.type.approve_topic: - class: phpbb\notification\type\approve_topic - scope: prototype # scope MUST be prototype for this to work! - arguments: - - @user_loader - - @dbal.conn - - @cache.driver - - @user - - @auth - - @config - - %core.root_path% - - %core.php_ext% - - %tables.notification_types% - - %tables.notifications% - - %tables.user_notifications% - tags: - - { name: notification.type } - - notification.type.bookmark: - class: phpbb\notification\type\bookmark - scope: prototype # scope MUST be prototype for this to work! - arguments: - - @user_loader - - @dbal.conn - - @cache.driver - - @user - - @auth - - @config - - %core.root_path% - - %core.php_ext% - - %tables.notification_types% - - %tables.notifications% - - %tables.user_notifications% - tags: - - { name: notification.type } - - notification.type.disapprove_post: - class: phpbb\notification\type\disapprove_post - scope: prototype # scope MUST be prototype for this to work! - arguments: - - @user_loader - - @dbal.conn - - @cache.driver - - @user - - @auth - - @config - - %core.root_path% - - %core.php_ext% - - %tables.notification_types% - - %tables.notifications% - - %tables.user_notifications% - tags: - - { name: notification.type } - - notification.type.disapprove_topic: - class: phpbb\notification\type\disapprove_topic - scope: prototype # scope MUST be prototype for this to work! - arguments: - - @user_loader - - @dbal.conn - - @cache.driver - - @user - - @auth - - @config - - %core.root_path% - - %core.php_ext% - - %tables.notification_types% - - %tables.notifications% - - %tables.user_notifications% - tags: - - { name: notification.type } - - notification.type.group_request: - class: phpbb\notification\type\group_request - scope: prototype # scope MUST be prototype for this to work! - arguments: - - @user_loader - - @dbal.conn - - @cache.driver - - @user - - @auth - - @config - - %core.root_path% - - %core.php_ext% - - %tables.notification_types% - - %tables.notifications% - - %tables.user_notifications% - tags: - - { name: notification.type } - - notification.type.group_request_approved: - class: phpbb\notification\type\group_request_approved - scope: prototype # scope MUST be prototype for this to work! - arguments: - - @user_loader - - @dbal.conn - - @cache.driver - - @user - - @auth - - @config - - %core.root_path% - - %core.php_ext% - - %tables.notification_types% - - %tables.notifications% - - %tables.user_notifications% - tags: - - { name: notification.type } - - notification.type.pm: - class: phpbb\notification\type\pm - scope: prototype # scope MUST be prototype for this to work! - arguments: - - @user_loader - - @dbal.conn - - @cache.driver - - @user - - @auth - - @config - - %core.root_path% - - %core.php_ext% - - %tables.notification_types% - - %tables.notifications% - - %tables.user_notifications% - tags: - - { name: notification.type } - - notification.type.post: - class: phpbb\notification\type\post - scope: prototype # scope MUST be prototype for this to work! - arguments: - - @user_loader - - @dbal.conn - - @cache.driver - - @user - - @auth - - @config - - %core.root_path% - - %core.php_ext% - - %tables.notification_types% - - %tables.notifications% - - %tables.user_notifications% - tags: - - { name: notification.type } - - notification.type.post_in_queue: - class: phpbb\notification\type\post_in_queue - scope: prototype # scope MUST be prototype for this to work! - arguments: - - @user_loader - - @dbal.conn - - @cache.driver - - @user - - @auth - - @config - - %core.root_path% - - %core.php_ext% - - %tables.notification_types% - - %tables.notifications% - - %tables.user_notifications% - tags: - - { name: notification.type } - - notification.type.quote: - class: phpbb\notification\type\quote - scope: prototype # scope MUST be prototype for this to work! - arguments: - - @user_loader - - @dbal.conn - - @cache.driver - - @user - - @auth - - @config - - %core.root_path% - - %core.php_ext% - - %tables.notification_types% - - %tables.notifications% - - %tables.user_notifications% - tags: - - { name: notification.type } - - notification.type.report_pm: - class: phpbb\notification\type\report_pm - scope: prototype # scope MUST be prototype for this to work! - arguments: - - @user_loader - - @dbal.conn - - @cache.driver - - @user - - @auth - - @config - - %core.root_path% - - %core.php_ext% - - %tables.notification_types% - - %tables.notifications% - - %tables.user_notifications% - tags: - - { name: notification.type } - - notification.type.report_pm_closed: - class: phpbb\notification\type\report_pm_closed - scope: prototype # scope MUST be prototype for this to work! - arguments: - - @user_loader - - @dbal.conn - - @cache.driver - - @user - - @auth - - @config - - %core.root_path% - - %core.php_ext% - - %tables.notification_types% - - %tables.notifications% - - %tables.user_notifications% - tags: - - { name: notification.type } - - notification.type.report_post: - class: phpbb\notification\type\report_post - scope: prototype # scope MUST be prototype for this to work! - arguments: - - @user_loader - - @dbal.conn - - @cache.driver - - @user - - @auth - - @config - - %core.root_path% - - %core.php_ext% - - %tables.notification_types% - - %tables.notifications% - - %tables.user_notifications% - tags: - - { name: notification.type } - - notification.type.report_post_closed: - class: phpbb\notification\type\report_post_closed - scope: prototype # scope MUST be prototype for this to work! - arguments: - - @user_loader - - @dbal.conn - - @cache.driver - - @user - - @auth - - @config - - %core.root_path% - - %core.php_ext% - - %tables.notification_types% - - %tables.notifications% - - %tables.user_notifications% - tags: - - { name: notification.type } - - notification.type.topic: - class: phpbb\notification\type\topic - scope: prototype # scope MUST be prototype for this to work! - arguments: - - @user_loader - - @dbal.conn - - @cache.driver - - @user - - @auth - - @config - - %core.root_path% - - %core.php_ext% - - %tables.notification_types% - - %tables.notifications% - - %tables.user_notifications% - tags: - - { name: notification.type } - - notification.type.topic_in_queue: - class: phpbb\notification\type\topic_in_queue - scope: prototype # scope MUST be prototype for this to work! - arguments: - - @user_loader - - @dbal.conn - - @cache.driver - - @user - - @auth - - @config - - %core.root_path% - - %core.php_ext% - - %tables.notification_types% - - %tables.notifications% - - %tables.user_notifications% - tags: - - { name: notification.type } - - notification.type.admin_activate_user: - class: phpbb\notification\type\admin_activate_user - scope: prototype # scope MUST be prototype for this to work! - arguments: - - @user_loader - - @dbal.conn - - @cache.driver - - @user - - @auth - - @config - - %core.root_path% - - %core.php_ext% - - %tables.notification_types% - - %tables.notifications% - - %tables.user_notifications% - tags: - - { name: notification.type } - - notification.method.email: - class: phpbb\notification\method\email - scope: prototype # scope MUST be prototype for this to work! - arguments: - - @user_loader - - @dbal.conn - - @cache.driver - - @user - - @auth - - @config - - %core.root_path% - - %core.php_ext% - tags: - - { name: notification.method } - - notification.method.jabber: - class: phpbb\notification\method\jabber - scope: prototype # scope MUST be prototype for this to work! - arguments: - - @user_loader - - @dbal.conn - - @cache.driver - - @user - - @auth - - @config - - %core.root_path% - - %core.php_ext% - tags: - - { name: notification.method } diff --git a/phpBB/config/default/services_password.yml b/phpBB/config/default/container/services_password.yml similarity index 100% rename from phpBB/config/default/services_password.yml rename to phpBB/config/default/container/services_password.yml diff --git a/phpBB/config/default/container/services_passwords.yml b/phpBB/config/default/container/services_passwords.yml deleted file mode 100644 index 3dc217286f..0000000000 --- a/phpBB/config/default/container/services_passwords.yml +++ /dev/null @@ -1,128 +0,0 @@ -parameters: - passwords.algorithms: - - passwords.driver.bcrypt_2y - - passwords.driver.bcrypt - - passwords.driver.salted_md5 - - passwords.driver.phpass - -services: - passwords.driver.bcrypt: - class: phpbb\passwords\driver\bcrypt - arguments: - - @config - - @passwords.driver_helper - tags: - - { name: passwords.driver } - - passwords.driver.bcrypt_2y: - class: phpbb\passwords\driver\bcrypt_2y - arguments: - - @config - - @passwords.driver_helper - tags: - - { name: passwords.driver } - - passwords.driver.bcrypt_wcf2: - class: phpbb\passwords\driver\bcrypt_wcf2 - arguments: - - @passwords.driver.bcrypt - - @passwords.driver_helper - tags: - - { name: passwords.driver } - - passwords.driver.salted_md5: - class: phpbb\passwords\driver\salted_md5 - arguments: - - @config - - @passwords.driver_helper - tags: - - { name: passwords.driver } - - passwords.driver.phpass: - class: phpbb\passwords\driver\phpass - arguments: - - @config - - @passwords.driver_helper - tags: - - { name: passwords.driver } - - passwords.driver.convert_password: - class: phpbb\passwords\driver\convert_password - arguments: - - @config - - @passwords.driver_helper - tags: - - { name: passwords.driver } - - passwords.driver.sha1_smf: - class: phpbb\passwords\driver\sha1_smf - arguments: - - @config - - @passwords.driver_helper - tags: - - { name: passwords.driver } - - passwords.driver.sha1_wcf1: - class: phpbb\passwords\driver\sha1_wcf1 - arguments: - - @config - - @passwords.driver_helper - tags: - - { name: passwords.driver } - - passwords.driver.sha1: - class: phpbb\passwords\driver\sha1 - arguments: - - @config - - @passwords.driver_helper - tags: - - { name: passwords.driver } - - passwords.driver.md5_phpbb2: - class: phpbb\passwords\driver\md5_phpbb2 - arguments: - - @request - - @passwords.driver.salted_md5 - - %core.root_path% - - %core.php_ext% - tags: - - { name: passwords.driver } - - passwords.driver.md5_mybb: - class: phpbb\passwords\driver\md5_mybb - arguments: - - @config - - @passwords.driver_helper - tags: - - { name: passwords.driver } - - passwords.driver.md5_vb: - class: phpbb\passwords\driver\md5_vb - arguments: - - @config - - @passwords.driver_helper - tags: - - { name: passwords.driver } - - passwords.driver_collection: - class: phpbb\di\service_collection - arguments: - - @service_container - tags: - - { name: service_collection, tag: passwords.driver } - - passwords.driver_helper: - class: phpbb\passwords\driver\helper - arguments: - - @config - - passwords.manager: - class: phpbb\passwords\manager - arguments: - - @config - - @passwords.driver_collection - - @passwords.helper - - %passwords.algorithms% - - passwords.helper: - class: phpbb\passwords\helper diff --git a/phpBB/config/default/services_profilefield.yml b/phpBB/config/default/container/services_profilefield.yml similarity index 100% rename from phpBB/config/default/services_profilefield.yml rename to phpBB/config/default/container/services_profilefield.yml diff --git a/phpBB/config/default/container/services_profilefields.yml b/phpBB/config/default/container/services_profilefields.yml deleted file mode 100644 index ce2a84b12b..0000000000 --- a/phpBB/config/default/container/services_profilefields.yml +++ /dev/null @@ -1,101 +0,0 @@ -services: - profilefields.manager: - class: phpbb\profilefields\manager - arguments: - - @auth - - @dbal.conn - - @dispatcher - - @request - - @template - - @profilefields.type_collection - - @user - - %tables.profile_fields% - - %tables.profile_fields_language% - - %tables.profile_fields_data% - - profilefields.lang_helper: - class: phpbb\profilefields\lang_helper - arguments: - - @dbal.conn - - %tables.profile_fields_options_language% - - profilefields.type_collection: - class: phpbb\di\service_collection - arguments: - - @service_container - tags: - - { name: service_collection, tag: profilefield.type } - - profilefields.type.bool: - class: phpbb\profilefields\type\type_bool - arguments: - - @profilefields.lang_helper - - @request - - @template - - @user - tags: - - { name: profilefield.type } - - profilefields.type.date: - class: phpbb\profilefields\type\type_date - arguments: - - @request - - @template - - @user - tags: - - { name: profilefield.type } - - profilefields.type.dropdown: - class: phpbb\profilefields\type\type_dropdown - arguments: - - @profilefields.lang_helper - - @request - - @template - - @user - tags: - - { name: profilefield.type } - - profilefields.type.googleplus: - class: phpbb\profilefields\type\type_googleplus - arguments: - - @request - - @template - - @user - tags: - - { name: profilefield.type } - - profilefields.type.int: - class: phpbb\profilefields\type\type_int - arguments: - - @request - - @template - - @user - tags: - - { name: profilefield.type } - - profilefields.type.string: - class: phpbb\profilefields\type\type_string - arguments: - - @request - - @template - - @user - tags: - - { name: profilefield.type } - - profilefields.type.text: - class: phpbb\profilefields\type\type_text - arguments: - - @request - - @template - - @user - tags: - - { name: profilefield.type } - - profilefields.type.url: - class: phpbb\profilefields\type\type_url - arguments: - - @request - - @template - - @user - tags: - - { name: profilefield.type } diff --git a/phpBB/config/default/services_user.yml b/phpBB/config/default/container/services_user.yml similarity index 100% rename from phpBB/config/default/services_user.yml rename to phpBB/config/default/container/services_user.yml From acc91a2bbf28656d4a6917b457ba3dd6b4e02e37 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Tue, 11 Nov 2014 17:59:41 +0100 Subject: [PATCH 26/37] [ticket/12620] Use the container to get the environment name PHPBB3-12620 --- phpBB/includes/functions_url_matcher.php | 8 ++++++-- phpBB/phpbb/cache/driver/file.php | 5 +++-- phpBB/phpbb/di/container_builder.php | 16 +++++++++++++--- phpBB/phpbb/di/extension/core.php | 2 +- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/phpBB/includes/functions_url_matcher.php b/phpBB/includes/functions_url_matcher.php index c06f4f6cb1..4f5ead6253 100644 --- a/phpBB/includes/functions_url_matcher.php +++ b/phpBB/includes/functions_url_matcher.php @@ -35,7 +35,9 @@ if (!defined('IN_PHPBB')) */ function phpbb_get_url_matcher(\phpbb\extension\manager $manager, RequestContext $context, $root_path, $php_ext) { - $config_cache = new ConfigCache($root_path . 'cache/' . PHPBB_ENVIRONMENT . '/url_matcher.' . $php_ext, defined('DEBUG')); + global $phpbb_container; + + $config_cache = new ConfigCache($root_path . 'cache/' . $phpbb_container->getParameter('core.environment') . '/url_matcher.' . $php_ext, defined('DEBUG')); if (!$config_cache->isFresh()) { phpbb_create_dumped_url_matcher($manager, $root_path, $config_cache); @@ -90,6 +92,8 @@ function phpbb_create_url_matcher(\phpbb\extension\manager $manager, RequestCont */ function phpbb_load_url_matcher(RequestContext $context, $root_path, $php_ext) { - require($root_path . 'cache/' . PHPBB_ENVIRONMENT . '/url_matcher.' . $php_ext); + global $phpbb_container; + + require($root_path . 'cache/' . $phpbb_container->getParameter('core.environment') . '/url_matcher.' . $php_ext); return new phpbb_url_matcher($context); } diff --git a/phpBB/phpbb/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php index d3708fe9a0..114959c06c 100644 --- a/phpBB/phpbb/cache/driver/file.php +++ b/phpBB/phpbb/cache/driver/file.php @@ -27,8 +27,9 @@ class file extends \phpbb\cache\driver\base */ function __construct($cache_dir = null) { - global $phpbb_root_path; - $this->cache_dir = !is_null($cache_dir) ? $cache_dir : $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/'; + global $phpbb_root_path, $phpbb_container; + + $this->cache_dir = !is_null($cache_dir) ? $cache_dir : $phpbb_root_path . 'cache/' . $phpbb_container->getParameter('core.environment') . '/'; if (!is_dir($this->cache_dir)) { diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index 6216dad978..c665c8444c 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -193,7 +193,7 @@ class container_builder } $loader = new YamlFileLoader($this->container, new FileLocator(phpbb_realpath($this->get_config_path()))); - $loader->load(PHPBB_ENVIRONMENT . '/config.yml'); + $loader->load($this->container->getParameter('core.environment') . '/config.yml'); $this->inject_custom_parameters(); @@ -327,7 +327,7 @@ class container_builder */ protected function get_cache_dir() { - return $this->cache_dir ?: $this->phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/'; + return $this->cache_dir ?: $this->phpbb_root_path . 'cache/' . $this->get_environment() . '/'; } /** @@ -457,7 +457,7 @@ class container_builder array( 'core.root_path' => $this->phpbb_root_path, 'core.php_ext' => $this->php_ext, - 'core.environment' => PHPBB_ENVIRONMENT, + 'core.environment' => $this->get_environment(), 'core.debug' => DEBUG, ), $this->get_env_parameters() @@ -495,4 +495,14 @@ class container_builder $filename = str_replace(array('/', '.'), array('slash', 'dot'), $this->phpbb_root_path); return $this->get_cache_dir() . 'container_' . $filename . '.' . $this->php_ext; } + + /** + * Return the name of the current environment. + * + * @return string + */ + protected function get_environment() + { + return PHPBB_ENVIRONMENT; + } } diff --git a/phpBB/phpbb/di/extension/core.php b/phpBB/phpbb/di/extension/core.php index 62fcf46ad5..ce0d4a869c 100644 --- a/phpBB/phpbb/di/extension/core.php +++ b/phpBB/phpbb/di/extension/core.php @@ -51,7 +51,7 @@ class core extends Extension public function load(array $configs, ContainerBuilder $container) { $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->config_path))); - $loader->load(PHPBB_ENVIRONMENT . '/container/environment.yml'); + $loader->load($container->getParameter('core.environment') . '/container/environment.yml'); $config = $this->getConfiguration($configs, $container); $config = $this->processConfiguration($config, $configs); From 0a1db77ea85116adf24f9d3f0b92a44f818a107f Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Tue, 11 Nov 2014 19:10:43 +0100 Subject: [PATCH 27/37] [ticket/12620] Add a test using a custom DI extension in an extension PHPBB3-12620 --- phpBB/phpbb/di/container_builder.php | 2 +- tests/di/create_container_test.php | 3 ++ .../ext/vendor/enabled_4/di/extension.php | 31 +++++++++++++++++++ .../ext/vendor/enabled_4/environment.yml | 2 ++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 tests/di/fixtures/ext/vendor/enabled_4/di/extension.php create mode 100644 tests/di/fixtures/ext/vendor/enabled_4/environment.yml diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index c665c8444c..62bba5baf9 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -162,7 +162,7 @@ class container_builder $installed_exts = $this->get_installed_extensions(); foreach ($installed_exts as $ext_name => $path) { - $extension_class = '\\' . str_replace('/', '\\', $ext_name) . '\\di\extension'; + $extension_class = '\\' . str_replace('/', '\\', $ext_name) . '\\di\\extension'; if (!class_exists($extension_class)) { diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index 4e47751999..9cc714db40 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -16,6 +16,7 @@ namespace define('PHPBB_ENVIRONMENT', 'production'); require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + require_once dirname(__FILE__) . '/fixtures/ext/vendor/enabled_4/di/extension.php'; class phpbb_di_container_test extends \phpbb_test_case { @@ -61,6 +62,7 @@ namespace $this->assertTrue($container->hasParameter('enabled')); $this->assertTrue($container->hasParameter('enabled_2')); $this->assertTrue($container->hasParameter('enabled_3')); + $this->assertTrue($container->hasParameter('enabled_4')); $this->assertFalse($container->hasParameter('disabled')); $this->assertFalse($container->hasParameter('available')); @@ -204,6 +206,7 @@ namespace phpbb\db\driver array('ext_name' => 'vendor/enabled'), array('ext_name' => 'vendor/enabled-2'), array('ext_name' => 'vendor/enabled-3'), + array('ext_name' => 'vendor/enabled_4'), ); } } diff --git a/tests/di/fixtures/ext/vendor/enabled_4/di/extension.php b/tests/di/fixtures/ext/vendor/enabled_4/di/extension.php new file mode 100644 index 0000000000..8342625687 --- /dev/null +++ b/tests/di/fixtures/ext/vendor/enabled_4/di/extension.php @@ -0,0 +1,31 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace vendor\enabled_4\di; + +use phpbb\extension\di\extension_base; +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; + +/** +* Container core extension +*/ +class extension extends extension_base +{ + protected function load_services(ContainerBuilder $container) + { + $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->ext_path))); + $loader->load('environment.yml'); + } +} diff --git a/tests/di/fixtures/ext/vendor/enabled_4/environment.yml b/tests/di/fixtures/ext/vendor/enabled_4/environment.yml new file mode 100644 index 0000000000..d0affe4fd6 --- /dev/null +++ b/tests/di/fixtures/ext/vendor/enabled_4/environment.yml @@ -0,0 +1,2 @@ +parameters: + enabled_4: true From 6019e51fedbb90f84a17155f1076af9aec37b65b Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 16 Nov 2014 17:28:44 +0100 Subject: [PATCH 28/37] [ticket/12620] Fix coding style PHPBB3-12620 --- phpBB/includes/functions_url_matcher.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/phpBB/includes/functions_url_matcher.php b/phpBB/includes/functions_url_matcher.php index 4f5ead6253..448f1b19a2 100644 --- a/phpBB/includes/functions_url_matcher.php +++ b/phpBB/includes/functions_url_matcher.php @@ -50,8 +50,7 @@ function phpbb_get_url_matcher(\phpbb\extension\manager $manager, RequestContext * Create a new UrlMatcher class and dump it into the cache file * * @param \phpbb\extension\manager $manager Extension manager -* @param string $root_path Root path - * @param ConfigCache $config_cache The config cache +* @param string $root_path Root path* @param ConfigCache $config_cache The config cache * @return null */ function phpbb_create_dumped_url_matcher(\phpbb\extension\manager $manager, $root_path, $config_cache) From 91daa736639fca67b2d330d0f20aabbd55eec2cf Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 19 Nov 2014 18:08:31 +0100 Subject: [PATCH 29/37] [ticket/12620] Fix session tests PHPBB3-12620 --- tests/session/testable_factory.php | 1 + tests/test_framework/phpbb_functional_test_case.php | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/tests/session/testable_factory.php b/tests/session/testable_factory.php index 3e25286480..505eb7006f 100644 --- a/tests/session/testable_factory.php +++ b/tests/session/testable_factory.php @@ -96,6 +96,7 @@ class phpbb_session_testable_factory 'auth.provider.db', new phpbb_mock_auth_provider() ); + $phpbb_container->setParameter('core.environment', PHPBB_ENVIRONMENT); $provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config); $provider_collection->add('auth.provider.db'); $phpbb_container->set( diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index cdb3d01524..9391795e32 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -204,6 +204,11 @@ class phpbb_functional_test_case extends phpbb_test_case { if (!$this->cache) { + global $phpbb_container; + + $phpbb_container = new phpbb_mock_container_builder(); + $phpbb_container->setParameter('core.environment', PHPBB_ENVIRONMENT); + $this->cache = new \phpbb\cache\driver\file; } From dd4f2387fd2f4df0e1513c251c9044f5bef60618 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 19 Nov 2014 19:50:07 +0100 Subject: [PATCH 30/37] [ticket/12620] Use the test environment for the tests PHPBB3-12620 --- build/build.xml | 2 ++ phpBB/config/test/config.yml | 5 +++++ phpBB/config/test/container/environment.yml | 3 +++ phpBB/config/test/container/parameters.yml | 2 ++ phpBB/config/test/container/services.yml | 2 ++ phpBB/config/test/routing.yml | 2 ++ tests/bootstrap.php | 2 +- tests/controller/config/{development => test}/routing.yml | 0 .../ext/vendor2/bar/config/{development => test}/routing.yml | 0 tests/di/create_container_test.php | 2 -- tests/di/fixtures/config/{development => test}/config.yml | 0 .../config/{development => test}/container/environment.yml | 0 .../config/{development => test}/container/environment.yml | 0 .../config/{development => test}/container/environment.yml | 0 .../fixtures/other_config/{development => test}/config.yml | 0 .../{development => test}/container/environment.yml | 0 tests/pagination/config/{development => test}/routing.yml | 0 17 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 phpBB/config/test/config.yml create mode 100644 phpBB/config/test/container/environment.yml create mode 100644 phpBB/config/test/container/parameters.yml create mode 100644 phpBB/config/test/container/services.yml create mode 100644 phpBB/config/test/routing.yml rename tests/controller/config/{development => test}/routing.yml (100%) rename tests/controller/ext/vendor2/bar/config/{development => test}/routing.yml (100%) rename tests/di/fixtures/config/{development => test}/config.yml (100%) rename tests/di/fixtures/config/{development => test}/container/environment.yml (100%) rename tests/di/fixtures/ext/vendor/disabled/config/{development => test}/container/environment.yml (100%) rename tests/di/fixtures/ext/vendor/enabled-2/config/{development => test}/container/environment.yml (100%) rename tests/di/fixtures/other_config/{development => test}/config.yml (100%) rename tests/di/fixtures/other_config/{development => test}/container/environment.yml (100%) rename tests/pagination/config/{development => test}/routing.yml (100%) diff --git a/build/build.xml b/build/build.xml index 5d143886af..16798f0e97 100644 --- a/build/build.xml +++ b/build/build.xml @@ -283,6 +283,8 @@ + + diff --git a/phpBB/config/test/config.yml b/phpBB/config/test/config.yml new file mode 100644 index 0000000000..1c17b08931 --- /dev/null +++ b/phpBB/config/test/config.yml @@ -0,0 +1,5 @@ +imports: + - { resource: ../default/config.yml } + +core: + require_dev_dependencies: true diff --git a/phpBB/config/test/container/environment.yml b/phpBB/config/test/container/environment.yml new file mode 100644 index 0000000000..40a3c7a683 --- /dev/null +++ b/phpBB/config/test/container/environment.yml @@ -0,0 +1,3 @@ +imports: + - { resource: services.yml } + - { resource: parameters.yml } diff --git a/phpBB/config/test/container/parameters.yml b/phpBB/config/test/container/parameters.yml new file mode 100644 index 0000000000..0447646806 --- /dev/null +++ b/phpBB/config/test/container/parameters.yml @@ -0,0 +1,2 @@ +imports: + - { resource: ../../default/container/parameters.yml } diff --git a/phpBB/config/test/container/services.yml b/phpBB/config/test/container/services.yml new file mode 100644 index 0000000000..b302f0f966 --- /dev/null +++ b/phpBB/config/test/container/services.yml @@ -0,0 +1,2 @@ +imports: + - { resource: ../../default/container/services.yml } diff --git a/phpBB/config/test/routing.yml b/phpBB/config/test/routing.yml new file mode 100644 index 0000000000..9ee3e5ae3a --- /dev/null +++ b/phpBB/config/test/routing.yml @@ -0,0 +1,2 @@ +core.default: + resource: "../default/routing.yml" diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 2fc8858585..ace48ea035 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -12,7 +12,7 @@ */ define('IN_PHPBB', true); -define('PHPBB_ENVIRONMENT', 'development'); +define('PHPBB_ENVIRONMENT', 'test'); $phpbb_root_path = 'phpBB/'; $phpEx = 'php'; diff --git a/tests/controller/config/development/routing.yml b/tests/controller/config/test/routing.yml similarity index 100% rename from tests/controller/config/development/routing.yml rename to tests/controller/config/test/routing.yml diff --git a/tests/controller/ext/vendor2/bar/config/development/routing.yml b/tests/controller/ext/vendor2/bar/config/test/routing.yml similarity index 100% rename from tests/controller/ext/vendor2/bar/config/development/routing.yml rename to tests/controller/ext/vendor2/bar/config/test/routing.yml diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index 9cc714db40..d52fb6b085 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -13,8 +13,6 @@ namespace { - define('PHPBB_ENVIRONMENT', 'production'); - require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/fixtures/ext/vendor/enabled_4/di/extension.php'; diff --git a/tests/di/fixtures/config/development/config.yml b/tests/di/fixtures/config/test/config.yml similarity index 100% rename from tests/di/fixtures/config/development/config.yml rename to tests/di/fixtures/config/test/config.yml diff --git a/tests/di/fixtures/config/development/container/environment.yml b/tests/di/fixtures/config/test/container/environment.yml similarity index 100% rename from tests/di/fixtures/config/development/container/environment.yml rename to tests/di/fixtures/config/test/container/environment.yml diff --git a/tests/di/fixtures/ext/vendor/disabled/config/development/container/environment.yml b/tests/di/fixtures/ext/vendor/disabled/config/test/container/environment.yml similarity index 100% rename from tests/di/fixtures/ext/vendor/disabled/config/development/container/environment.yml rename to tests/di/fixtures/ext/vendor/disabled/config/test/container/environment.yml diff --git a/tests/di/fixtures/ext/vendor/enabled-2/config/development/container/environment.yml b/tests/di/fixtures/ext/vendor/enabled-2/config/test/container/environment.yml similarity index 100% rename from tests/di/fixtures/ext/vendor/enabled-2/config/development/container/environment.yml rename to tests/di/fixtures/ext/vendor/enabled-2/config/test/container/environment.yml diff --git a/tests/di/fixtures/other_config/development/config.yml b/tests/di/fixtures/other_config/test/config.yml similarity index 100% rename from tests/di/fixtures/other_config/development/config.yml rename to tests/di/fixtures/other_config/test/config.yml diff --git a/tests/di/fixtures/other_config/development/container/environment.yml b/tests/di/fixtures/other_config/test/container/environment.yml similarity index 100% rename from tests/di/fixtures/other_config/development/container/environment.yml rename to tests/di/fixtures/other_config/test/container/environment.yml diff --git a/tests/pagination/config/development/routing.yml b/tests/pagination/config/test/routing.yml similarity index 100% rename from tests/pagination/config/development/routing.yml rename to tests/pagination/config/test/routing.yml From ac0ff219c61bd187dd3fbde5b6808624bd8ef077 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 19 Nov 2014 20:04:00 +0100 Subject: [PATCH 31/37] [ticket/12620] Move the routing.yml file to routing/environment.yml PHPBB3-12620 --- phpBB/config/default/{ => routing}/routing.yml | 0 phpBB/config/development/{routing.yml => routing/environment.yml} | 0 phpBB/config/production/{routing.yml => routing/environment.yml} | 0 phpBB/config/test/{routing.yml => routing/environment.yml} | 0 .../config/test/{routing.yml => routing/environment.yml} | 0 .../bar/config/test/{routing.yml => routing/environment.yml} | 0 .../config/test/{routing.yml => routing/environment.yml} | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename phpBB/config/default/{ => routing}/routing.yml (100%) rename phpBB/config/development/{routing.yml => routing/environment.yml} (100%) rename phpBB/config/production/{routing.yml => routing/environment.yml} (100%) rename phpBB/config/test/{routing.yml => routing/environment.yml} (100%) rename tests/controller/config/test/{routing.yml => routing/environment.yml} (100%) rename tests/controller/ext/vendor2/bar/config/test/{routing.yml => routing/environment.yml} (100%) rename tests/pagination/config/test/{routing.yml => routing/environment.yml} (100%) diff --git a/phpBB/config/default/routing.yml b/phpBB/config/default/routing/routing.yml similarity index 100% rename from phpBB/config/default/routing.yml rename to phpBB/config/default/routing/routing.yml diff --git a/phpBB/config/development/routing.yml b/phpBB/config/development/routing/environment.yml similarity index 100% rename from phpBB/config/development/routing.yml rename to phpBB/config/development/routing/environment.yml diff --git a/phpBB/config/production/routing.yml b/phpBB/config/production/routing/environment.yml similarity index 100% rename from phpBB/config/production/routing.yml rename to phpBB/config/production/routing/environment.yml diff --git a/phpBB/config/test/routing.yml b/phpBB/config/test/routing/environment.yml similarity index 100% rename from phpBB/config/test/routing.yml rename to phpBB/config/test/routing/environment.yml diff --git a/tests/controller/config/test/routing.yml b/tests/controller/config/test/routing/environment.yml similarity index 100% rename from tests/controller/config/test/routing.yml rename to tests/controller/config/test/routing/environment.yml diff --git a/tests/controller/ext/vendor2/bar/config/test/routing.yml b/tests/controller/ext/vendor2/bar/config/test/routing/environment.yml similarity index 100% rename from tests/controller/ext/vendor2/bar/config/test/routing.yml rename to tests/controller/ext/vendor2/bar/config/test/routing/environment.yml diff --git a/tests/pagination/config/test/routing.yml b/tests/pagination/config/test/routing/environment.yml similarity index 100% rename from tests/pagination/config/test/routing.yml rename to tests/pagination/config/test/routing/environment.yml From 48950be82bca0c85347f5aa1585de44c369780c6 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 19 Nov 2014 20:54:14 +0100 Subject: [PATCH 32/37] [ticket/12620] Fix tests PHPBB3-12620 --- phpBB/config/development/routing/environment.yml | 2 +- phpBB/config/production/routing/environment.yml | 2 +- phpBB/config/test/routing/environment.yml | 2 +- phpBB/includes/functions_install.php | 10 +--------- phpBB/includes/functions_url_matcher.php | 8 ++++++-- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/phpBB/config/development/routing/environment.yml b/phpBB/config/development/routing/environment.yml index 9ee3e5ae3a..0cddfb7521 100644 --- a/phpBB/config/development/routing/environment.yml +++ b/phpBB/config/development/routing/environment.yml @@ -1,2 +1,2 @@ core.default: - resource: "../default/routing.yml" + resource: "../../default/routing/routing.yml" diff --git a/phpBB/config/production/routing/environment.yml b/phpBB/config/production/routing/environment.yml index 9ee3e5ae3a..0cddfb7521 100644 --- a/phpBB/config/production/routing/environment.yml +++ b/phpBB/config/production/routing/environment.yml @@ -1,2 +1,2 @@ core.default: - resource: "../default/routing.yml" + resource: "../../default/routing/routing.yml" diff --git a/phpBB/config/test/routing/environment.yml b/phpBB/config/test/routing/environment.yml index 9ee3e5ae3a..0cddfb7521 100644 --- a/phpBB/config/test/routing/environment.yml +++ b/phpBB/config/test/routing/environment.yml @@ -1,2 +1,2 @@ core.default: - resource: "../default/routing.yml" + resource: "../../default/routing/routing.yml" diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index cdd9c7864b..ef4e3166e3 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -450,15 +450,7 @@ function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_cont $config_data .= "\n@define('PHPBB_INSTALLED', true);\n"; $config_data .= "// @define('PHPBB_DISPLAY_LOAD_TIME', true);\n"; - - if ($debug) - { - $config_data .= "@define('PHPBB_ENVIRONMENT', 'development');\n"; - } - else - { - $config_data .= "@define('PHPBB_ENVIRONMENT', 'production');\n"; - } + $config_data .= "@define('PHPBB_ENVIRONMENT', 'test');\n"; if ($debug_container) { diff --git a/phpBB/includes/functions_url_matcher.php b/phpBB/includes/functions_url_matcher.php index 448f1b19a2..19aebd1fbc 100644 --- a/phpBB/includes/functions_url_matcher.php +++ b/phpBB/includes/functions_url_matcher.php @@ -55,7 +55,9 @@ function phpbb_get_url_matcher(\phpbb\extension\manager $manager, RequestContext */ function phpbb_create_dumped_url_matcher(\phpbb\extension\manager $manager, $root_path, $config_cache) { - $provider = new \phpbb\controller\provider($root_path); + global $phpbb_container; + + $provider = new \phpbb\controller\provider($phpbb_container->getParameter('core.environment'), $root_path); $provider->find_routing_files($manager->all_enabled()); $routes = $provider->find()->get_routes(); $dumper = new PhpMatcherDumper($routes); @@ -75,7 +77,9 @@ function phpbb_create_dumped_url_matcher(\phpbb\extension\manager $manager, $roo */ function phpbb_create_url_matcher(\phpbb\extension\manager $manager, RequestContext $context, $root_path) { - $provider = new \phpbb\controller\provider($root_path); + global $phpbb_container; + + $provider = new \phpbb\controller\provider($phpbb_container->getParameter('core.environment'), $root_path); $provider->find_routing_files($manager->all_enabled()); $routes = $provider->find()->get_routes(); return new UrlMatcher($routes, $context); From 93f61a4a7d34f8ad565bdc1605784284994ecdfc Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 20 Nov 2014 18:38:32 +0100 Subject: [PATCH 33/37] [ticket/12620] Use the right environment while installing PHPBB3-12620 --- phpBB/includes/functions_install.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index ef4e3166e3..a60ddd40c5 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -450,7 +450,19 @@ function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_cont $config_data .= "\n@define('PHPBB_INSTALLED', true);\n"; $config_data .= "// @define('PHPBB_DISPLAY_LOAD_TIME', true);\n"; - $config_data .= "@define('PHPBB_ENVIRONMENT', 'test');\n"; + + if ($debug_test) + { + $config_data .= "@define('PHPBB_ENVIRONMENT', 'test');\n"; + } + else if ($debug) + { + $config_data .= "@define('PHPBB_ENVIRONMENT', 'development');\n"; + } + else + { + $config_data .= "@define('PHPBB_ENVIRONMENT', 'production');\n"; + } if ($debug_container) { From 677b5b2cd4937ee6c777728082084c661223dee8 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 20 Nov 2014 22:40:37 +0100 Subject: [PATCH 34/37] [ticket/12620] Fix rebase PHPBB3-12620 --- phpBB/config/default/container/services.yml | 1 + phpBB/phpbb/controller/helper.php | 5 +- phpBB/phpbb/di/container_builder.php | 2 +- phpBB/phpbb/di/extension/core.php | 40 ++--- phpBB/phpbb/extension/di/extension_base.php | 4 +- phpBB/phpbb/routing/router.php | 180 +++++++++++--------- tests/avatar/driver/barfoo.php | 52 +++--- tests/avatar/driver/foobar.php | 52 +++--- tests/controller/common_helper_route.php | 6 +- tests/controller/controller_test.php | 4 +- tests/pagination/pagination_test.php | 10 +- 11 files changed, 188 insertions(+), 168 deletions(-) diff --git a/phpBB/config/default/container/services.yml b/phpBB/config/default/container/services.yml index 3f36a5178a..6cf9180cc0 100644 --- a/phpBB/config/default/container/services.yml +++ b/phpBB/config/default/container/services.yml @@ -157,6 +157,7 @@ services: - @ext.manager - %core.root_path% - %core.php_ext% + - %core.environment% router.listener: class: Symfony\Component\HttpKernel\EventListener\RouterListener diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index cc327882e0..2bc8e6b9d0 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -41,8 +41,9 @@ class helper protected $config; /** - * @var \phpbb\routing\router phpBB router - */ + * phpBB router + * @var \phpbb\routing\router + */ protected $router; /* @var \phpbb\symfony_request */ diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index 62bba5baf9..125ae28e9b 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -19,7 +19,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Dumper\PhpDumper; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; -use Symfony\Component\HttpKernel\DependencyInjection\RegisterListenersPass; +use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass; use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; class container_builder diff --git a/phpBB/phpbb/di/extension/core.php b/phpBB/phpbb/di/extension/core.php index ce0d4a869c..72d46fb05b 100644 --- a/phpBB/phpbb/di/extension/core.php +++ b/phpBB/phpbb/di/extension/core.php @@ -25,29 +25,29 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension; class core extends Extension { /** - * Config path - * @var string - */ + * Config path + * @var string + */ protected $config_path; /** - * Constructor - * - * @param string $config_path Config path - */ + * Constructor + * + * @param string $config_path Config path + */ public function __construct($config_path) { $this->config_path = $config_path; } /** - * 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 - */ + * 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) { $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->config_path))); @@ -81,12 +81,12 @@ class core extends Extension } /** - * Returns the recommended alias to use in XML. - * - * This alias is also the mandatory prefix to use when using YAML. - * - * @return string The alias - */ + * 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 'core'; diff --git a/phpBB/phpbb/extension/di/extension_base.php b/phpBB/phpbb/extension/di/extension_base.php index 74026bd53a..30cc37dbb6 100644 --- a/phpBB/phpbb/extension/di/extension_base.php +++ b/phpBB/phpbb/extension/di/extension_base.php @@ -20,8 +20,8 @@ use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\HttpKernel\DependencyInjection\Extension; /** -* Container core extension -*/ + * Container core extension + */ class extension_base extends Extension { /** diff --git a/phpBB/phpbb/routing/router.php b/phpBB/phpbb/routing/router.php index f721837bba..0617e94c93 100644 --- a/phpBB/phpbb/routing/router.php +++ b/phpBB/phpbb/routing/router.php @@ -25,95 +25,119 @@ use Symfony\Component\Config\FileLocator; use phpbb\extension\manager; /** -* Integration of all pieces of the routing system for easier use. -*/ + * Integration of all pieces of the routing system for easier use. + */ class router implements RouterInterface { /** - * @var manager Extension manager - */ + * Extension manager + * + * @var manager + */ protected $extension_manager; /** - * @var string phpBB root path - */ + * phpBB root path + * + * @var string + */ protected $phpbb_root_path; /** - * @var string PHP file extensions - */ + * PHP file extensions + * + * @var string + */ protected $php_ext; /** - * @var array YAML file(s) containing route information - */ + * Name of the current environment + * + * @var string + */ + protected $environment; + + /** + * YAML file(s) containing route information + * + * @var array + */ protected $routing_files; /** - * @var \Symfony\Component\Routing\Matcher\UrlMatcherInterface|null - */ + * @var \Symfony\Component\Routing\Matcher\UrlMatcherInterface|null + */ protected $matcher; /** - * @var \Symfony\Component\Routing\Generator\UrlGeneratorInterface|null - */ + * @var \Symfony\Component\Routing\Generator\UrlGeneratorInterface|null + */ protected $generator; /** - * @var RequestContext - */ + * @var RequestContext + */ protected $context; /** - * @var RouteCollection|null - */ + * @var RouteCollection|null + */ protected $route_collection; /** - * Construct method - * - * @param manager $extension_manager The extension manager - * @param string $phpbb_root_path phpBB root path - * @param string $php_ext PHP file extension - * @param array $routing_files Array of strings containing paths to YAML files holding route information - */ - public function __construct(manager $extension_manager, $phpbb_root_path, $php_ext, $routing_files = array()) + * Construct method + * + * @param manager $extension_manager Extension manager + * @param string $phpbb_root_path phpBB root path + * @param string $php_ext PHP file extension + * @param string $environment Name of the current environment + * @param array $routing_files Array of strings containing paths to YAML files holding route information + */ + public function __construct(manager $extension_manager, $phpbb_root_path, $php_ext, $environment, $routing_files = array()) { $this->extension_manager = $extension_manager; $this->routing_files = $routing_files; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; + $this->environment = $environment; $this->context = new RequestContext(); } /** - * Find the list of routing files - * - * @param \phpbb\finder $finder - * @return router - */ - public function find_routing_files(\phpbb\finder $finder) + * Find the list of routing files + * + * @param array $paths Array of paths where to look for routing files. + * @return null + */ + public function find_routing_files(array $paths) { - if ($this->routing_files === null || empty($this->routing_files)) + $this->routing_files = array($this->phpbb_root_path . 'config/' . $this->environment . '/routing/environment.yml'); + foreach ($paths as $path) { - // We hardcode the path to the core config directory - // because the finder cannot find it - $this->routing_files = array_merge($this->routing_files, array('config/routing.yml'), array_keys($finder - ->directory('/config') - ->suffix('routing.yml') - ->find() - )); + if (file_exists($path . 'config/' . $this->environment . '/routing/environment.yml')) + { + $this->routing_files[] = $path . 'config/' . $this->environment . '/routing/environment.yml'; + } + else if (!is_dir($path . 'config/' . $this->environment)) + { + if (file_exists($path . 'config/default/routing/environment.yml')) + { + $this->routing_files[] = $path . 'config/default/routing/environment.yml'; + } + else if (!is_dir($path . 'config/default/routing') && file_exists($path . 'config/routing.yml')) + { + $this->routing_files[] = $path . 'config/routing.yml'; + } + } } - - return $this; } /** - * Find a list of controllers - * - * @param string $base_path Base path to prepend to file paths - * @return router - */ + * Find a list of controllers + * + * @param string $base_path Base path to prepend to file paths + * @return router + */ public function find($base_path = '') { if ($this->route_collection === null || $this->route_collection->count() === 0) @@ -130,15 +154,15 @@ class router implements RouterInterface } /** - * Get the list of routes - * - * @return RouteCollection Get the route collection - */ + * Get the list of routes + * + * @return RouteCollection Get the route collection + */ public function get_routes() { if ($this->route_collection == null || empty($this->routing_files)) { - $this->find_routing_files($this->extension_manager->get_finder()) + $this->find_routing_files($this->extension_manager->all_enabled()) ->find($this->phpbb_root_path); } @@ -146,16 +170,16 @@ class router implements RouterInterface } /** - * {@inheritdoc} - */ + * {@inheritdoc} + */ public function getRouteCollection() { return $this->get_routes(); } /** - * {@inheritdoc} - */ + * {@inheritdoc} + */ public function setContext(RequestContext $context) { $this->context = $context; @@ -171,34 +195,34 @@ class router implements RouterInterface } /** - * {@inheritdoc} - */ + * {@inheritdoc} + */ public function getContext() { return $this->context; } /** - * {@inheritdoc} - */ + * {@inheritdoc} + */ public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) { return $this->get_generator()->generate($name, $parameters, $referenceType); } /** - * {@inheritdoc} - */ + * {@inheritdoc} + */ public function match($pathinfo) { return $this->get_matcher()->match($pathinfo); } /** - * Gets the UrlMatcher instance associated with this Router. - * - * @return \Symfony\Component\Routing\Matcher\UrlMatcherInterface A UrlMatcherInterface instance - */ + * Gets the UrlMatcher instance associated with this Router. + * + * @return \Symfony\Component\Routing\Matcher\UrlMatcherInterface A UrlMatcherInterface instance + */ public function get_matcher() { if ($this->matcher !== null) @@ -218,8 +242,8 @@ class router implements RouterInterface return $this->matcher; } /** - * Creates a new dumped URL Matcher (dump it if necessary) - */ + * Creates a new dumped URL Matcher (dump it if necessary) + */ protected function create_dumped_url_matcher() { if (!file_exists($this->phpbb_root_path . 'cache/url_matcher.' . $this->php_ext)) @@ -240,18 +264,18 @@ class router implements RouterInterface } /** - * Creates a new URL Matcher - */ + * Creates a new URL Matcher + */ protected function create_new_url_matcher() { $this->matcher = new UrlMatcher($this->get_routes(), $this->context); } /** - * Gets the UrlGenerator instance associated with this Router. - * - * @return \Symfony\Component\Routing\Generator\UrlGeneratorInterface A UrlGeneratorInterface instance - */ + * Gets the UrlGenerator instance associated with this Router. + * + * @return \Symfony\Component\Routing\Generator\UrlGeneratorInterface A UrlGeneratorInterface instance + */ public function get_generator() { if ($this->generator !== null) @@ -272,8 +296,8 @@ class router implements RouterInterface } /** - * Creates a new dumped URL Generator (dump it if necessary) - */ + * Creates a new dumped URL Generator (dump it if necessary) + */ protected function create_dumped_url_generator() { if (!file_exists($this->phpbb_root_path . 'cache/url_generator.' . $this->php_ext)) @@ -294,8 +318,8 @@ class router implements RouterInterface } /** - * Creates a new URL Generator - */ + * Creates a new URL Generator + */ protected function create_new_url_generator() { $this->generator = new UrlGenerator($this->get_routes(), $this->context); diff --git a/tests/avatar/driver/barfoo.php b/tests/avatar/driver/barfoo.php index 0bf30b8a91..067bb3ef97 100644 --- a/tests/avatar/driver/barfoo.php +++ b/tests/avatar/driver/barfoo.php @@ -1,26 +1,26 @@ -router = new phpbb_mock_router($this->extension_manager, dirname(__FILE__) . '/', 'php'); - $this->router->find_routing_files($finder); + $this->router = new phpbb_mock_router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $this->router->find_routing_files($this->extension_manager->all_enabled()); $this->router->find(dirname(__FILE__) . '/'); // Set correct current phpBB root path $this->root_path = $this->get_phpbb_root_path(); @@ -319,7 +319,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description); } -//TODO + public function helper_url_data_absolute_with_rewrite() { return array( diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index 637e9685e6..354a902831 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -40,8 +40,8 @@ class phpbb_controller_controller_test extends phpbb_test_case public function test_router_find_files() { - $router = new \phpbb\routing\router($this->extension_manager, dirname(__FILE__) . '/', 'php'); - $router->find_routing_files($this->extension_manager->get_finder()); + $router = new \phpbb\routing\router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $router->find_routing_files($this->extension_manager->all_enabled()); $routes = $router->find(__DIR__)->get_routes(); // This will need to be updated if any new routes are defined diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index 04f7b807a7..1b9e8c751c 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -36,16 +36,10 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case $filesystem = new \phpbb\filesystem(); $manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array()); - $finder = new \phpbb\finder( - $filesystem, - dirname(__FILE__) . '/', - new phpbb_mock_cache() - ); - $finder->set_extensions(array_keys($manager->all_enabled())); $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $router = new phpbb_mock_router($manager, dirname(__FILE__) . '/', 'php'); - $router->find_routing_files($finder); + $router = new phpbb_mock_router($manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $router->find_routing_files($manager->all_enabled()); $router->find(dirname(__FILE__) . '/'); $request = new phpbb_mock_request(); From f5c5f7df755dd930fef4de6f62e42d4a2a54219e Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 21 Nov 2014 08:26:19 +0100 Subject: [PATCH 35/37] [ticket/12620] Fix functionnal tests PHPBB3-12620 --- phpBB/phpbb/routing/router.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/phpBB/phpbb/routing/router.php b/phpBB/phpbb/routing/router.php index 0617e94c93..1003708540 100644 --- a/phpBB/phpbb/routing/router.php +++ b/phpBB/phpbb/routing/router.php @@ -107,7 +107,7 @@ class router implements RouterInterface * Find the list of routing files * * @param array $paths Array of paths where to look for routing files. - * @return null + * @return router */ public function find_routing_files(array $paths) { @@ -130,6 +130,8 @@ class router implements RouterInterface } } } + + return $this; } /** From 5e2896bb00089518547d2863fd119cd8a4bcf518 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 21 Nov 2014 16:42:01 +0100 Subject: [PATCH 36/37] [ticket/12620] Remove the old includes/functions_url_matcher.php file PHPBB3-12620 --- phpBB/includes/functions_url_matcher.php | 102 ----------------------- 1 file changed, 102 deletions(-) delete mode 100644 phpBB/includes/functions_url_matcher.php diff --git a/phpBB/includes/functions_url_matcher.php b/phpBB/includes/functions_url_matcher.php deleted file mode 100644 index 19aebd1fbc..0000000000 --- a/phpBB/includes/functions_url_matcher.php +++ /dev/null @@ -1,102 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -use Symfony\Component\Config\ConfigCache; -use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper; -use Symfony\Component\Routing\Matcher\UrlMatcher; -use Symfony\Component\Routing\RequestContext; - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Create a new UrlMatcher class and dump it into the cache file -* -* @param \phpbb\extension\manager $manager Extension manager -* @param RequestContext $context Symfony RequestContext object -* @param string $root_path Root path -* @param string $php_ext PHP file extension -* @return null -*/ -function phpbb_get_url_matcher(\phpbb\extension\manager $manager, RequestContext $context, $root_path, $php_ext) -{ - global $phpbb_container; - - $config_cache = new ConfigCache($root_path . 'cache/' . $phpbb_container->getParameter('core.environment') . '/url_matcher.' . $php_ext, defined('DEBUG')); - if (!$config_cache->isFresh()) - { - phpbb_create_dumped_url_matcher($manager, $root_path, $config_cache); - } - - return phpbb_load_url_matcher($context, $root_path, $php_ext); -} - -/** -* Create a new UrlMatcher class and dump it into the cache file -* -* @param \phpbb\extension\manager $manager Extension manager -* @param string $root_path Root path* @param ConfigCache $config_cache The config cache -* @return null -*/ -function phpbb_create_dumped_url_matcher(\phpbb\extension\manager $manager, $root_path, $config_cache) -{ - global $phpbb_container; - - $provider = new \phpbb\controller\provider($phpbb_container->getParameter('core.environment'), $root_path); - $provider->find_routing_files($manager->all_enabled()); - $routes = $provider->find()->get_routes(); - $dumper = new PhpMatcherDumper($routes); - $cached_url_matcher_dump = $dumper->dump(array( - 'class' => 'phpbb_url_matcher', - )); - - $config_cache->write($cached_url_matcher_dump, $routes->getResources()); -} - -/** -* Create a non-cached UrlMatcher -* -* @param \phpbb\extension\manager $manager Extension manager -* @param RequestContext $context Symfony RequestContext object -* @return UrlMatcher -*/ -function phpbb_create_url_matcher(\phpbb\extension\manager $manager, RequestContext $context, $root_path) -{ - global $phpbb_container; - - $provider = new \phpbb\controller\provider($phpbb_container->getParameter('core.environment'), $root_path); - $provider->find_routing_files($manager->all_enabled()); - $routes = $provider->find()->get_routes(); - return new UrlMatcher($routes, $context); -} - -/** -* Load the cached phpbb_url_matcher class -* -* @param RequestContext $context Symfony RequestContext object -* @param string $root_path Root path -* @param string $php_ext PHP file extension -* @return phpbb_url_matcher -*/ -function phpbb_load_url_matcher(RequestContext $context, $root_path, $php_ext) -{ - global $phpbb_container; - - require($root_path . 'cache/' . $phpbb_container->getParameter('core.environment') . '/url_matcher.' . $php_ext); - return new phpbb_url_matcher($context); -} From 54d529994029564d5cecbec2aaac36a0544552a0 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 21 Nov 2014 17:38:13 +0100 Subject: [PATCH 37/37] [ticket/12620] Fix tests PHPBB3-12620 --- phpBB/app.php | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/app.php b/phpBB/app.php index d9250adc75..10909f7103 100644 --- a/phpBB/app.php +++ b/phpBB/app.php @@ -21,7 +21,6 @@ define('IN_PHPBB', true); $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); -include($phpbb_root_path . 'includes/functions_url_matcher.' . $phpEx); // Start session management $user->session_begin();