From 873260589eaa7ac2d7e520ebe321cb8bb2609ce0 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 30 May 2014 15:29:09 +0200 Subject: [ticket/12620] Display error message when the environment isn't available PHPBB3-12620 --- phpBB/common.php | 23 +++++++++++++++++++++-- phpBB/config/config_debug.yml | 2 -- phpBB/config/config_productive.yml | 2 -- phpBB/config/environment_debug.yml | 2 ++ phpBB/config/environment_productive.yml | 2 ++ phpBB/phpbb/di/extension/core.php | 2 +- 6 files changed, 26 insertions(+), 7 deletions(-) delete mode 100644 phpBB/config/config_debug.yml delete mode 100644 phpBB/config/config_productive.yml create mode 100644 phpBB/config/environment_debug.yml create mode 100644 phpBB/config/environment_productive.yml (limited to 'phpBB') 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/config_debug.yml deleted file mode 100644 index 6982aa4f83..0000000000 --- a/phpBB/config/config_debug.yml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: services.yml } diff --git a/phpBB/config/config_productive.yml b/phpBB/config/config_productive.yml deleted file mode 100644 index 6982aa4f83..0000000000 --- a/phpBB/config/config_productive.yml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: services.yml } diff --git a/phpBB/config/environment_debug.yml b/phpBB/config/environment_debug.yml new file mode 100644 index 0000000000..6982aa4f83 --- /dev/null +++ b/phpBB/config/environment_debug.yml @@ -0,0 +1,2 @@ +imports: + - { resource: services.yml } diff --git a/phpBB/config/environment_productive.yml b/phpBB/config/environment_productive.yml new file mode 100644 index 0000000000..6982aa4f83 --- /dev/null +++ b/phpBB/config/environment_productive.yml @@ -0,0 +1,2 @@ +imports: + - { resource: services.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'); } /** -- cgit v1.2.1