Skip to content

Commit acc91a2

Browse files
committed
[ticket/12620] Use the container to get the environment name
PHPBB3-12620
1 parent c98efc5 commit acc91a2

4 files changed

Lines changed: 23 additions & 8 deletions

File tree

phpBB/includes/functions_url_matcher.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
*/
3636
function phpbb_get_url_matcher(\phpbb\extension\manager $manager, RequestContext $context, $root_path, $php_ext)
3737
{
38-
$config_cache = new ConfigCache($root_path . 'cache/' . PHPBB_ENVIRONMENT . '/url_matcher.' . $php_ext, defined('DEBUG'));
38+
global $phpbb_container;
39+
40+
$config_cache = new ConfigCache($root_path . 'cache/' . $phpbb_container->getParameter('core.environment') . '/url_matcher.' . $php_ext, defined('DEBUG'));
3941
if (!$config_cache->isFresh())
4042
{
4143
phpbb_create_dumped_url_matcher($manager, $root_path, $config_cache);
@@ -90,6 +92,8 @@ function phpbb_create_url_matcher(\phpbb\extension\manager $manager, RequestCont
9092
*/
9193
function phpbb_load_url_matcher(RequestContext $context, $root_path, $php_ext)
9294
{
93-
require($root_path . 'cache/' . PHPBB_ENVIRONMENT . '/url_matcher.' . $php_ext);
95+
global $phpbb_container;
96+
97+
require($root_path . 'cache/' . $phpbb_container->getParameter('core.environment') . '/url_matcher.' . $php_ext);
9498
return new phpbb_url_matcher($context);
9599
}

phpBB/phpbb/cache/driver/file.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ class file extends \phpbb\cache\driver\base
2727
*/
2828
function __construct($cache_dir = null)
2929
{
30-
global $phpbb_root_path;
31-
$this->cache_dir = !is_null($cache_dir) ? $cache_dir : $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/';
30+
global $phpbb_root_path, $phpbb_container;
31+
32+
$this->cache_dir = !is_null($cache_dir) ? $cache_dir : $phpbb_root_path . 'cache/' . $phpbb_container->getParameter('core.environment') . '/';
3233

3334
if (!is_dir($this->cache_dir))
3435
{

phpBB/phpbb/di/container_builder.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public function get_container()
193193
}
194194

195195
$loader = new YamlFileLoader($this->container, new FileLocator(phpbb_realpath($this->get_config_path())));
196-
$loader->load(PHPBB_ENVIRONMENT . '/config.yml');
196+
$loader->load($this->container->getParameter('core.environment') . '/config.yml');
197197

198198
$this->inject_custom_parameters();
199199

@@ -327,7 +327,7 @@ public function set_cache_dir($cache_dir)
327327
*/
328328
protected function get_cache_dir()
329329
{
330-
return $this->cache_dir ?: $this->phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/';
330+
return $this->cache_dir ?: $this->phpbb_root_path . 'cache/' . $this->get_environment() . '/';
331331
}
332332

333333
/**
@@ -457,7 +457,7 @@ protected function get_core_parameters()
457457
array(
458458
'core.root_path' => $this->phpbb_root_path,
459459
'core.php_ext' => $this->php_ext,
460-
'core.environment' => PHPBB_ENVIRONMENT,
460+
'core.environment' => $this->get_environment(),
461461
'core.debug' => DEBUG,
462462
),
463463
$this->get_env_parameters()
@@ -495,4 +495,14 @@ protected function get_container_filename()
495495
$filename = str_replace(array('/', '.'), array('slash', 'dot'), $this->phpbb_root_path);
496496
return $this->get_cache_dir() . 'container_' . $filename . '.' . $this->php_ext;
497497
}
498+
499+
/**
500+
* Return the name of the current environment.
501+
*
502+
* @return string
503+
*/
504+
protected function get_environment()
505+
{
506+
return PHPBB_ENVIRONMENT;
507+
}
498508
}

phpBB/phpbb/di/extension/core.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct($config_path)
5151
public function load(array $configs, ContainerBuilder $container)
5252
{
5353
$loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->config_path)));
54-
$loader->load(PHPBB_ENVIRONMENT . '/container/environment.yml');
54+
$loader->load($container->getParameter('core.environment') . '/container/environment.yml');
5555

5656
$config = $this->getConfiguration($configs, $container);
5757
$config = $this->processConfiguration($config, $configs);

0 commit comments

Comments
 (0)