From 873260589eaa7ac2d7e520ebe321cb8bb2609ce0 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 30 May 2014 15:29:09 +0200 Subject: [PATCH] [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'); } /**