aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Darricau <tristan.darricau@sensiolabs.com>2015-12-11 21:31:27 +0100
committerTristan Darricau <tristan.darricau@sensiolabs.com>2016-01-09 15:35:17 +0100
commit78349ed80f24cb61ad05f997e97d805cc5b0409f (patch)
treea9daf2a506047e74c585beadf601ff697fd4f34a
parentf6524f4902bc843908ade3583d5453ce58b5327a (diff)
downloadforums-78349ed80f24cb61ad05f997e97d805cc5b0409f.tar
forums-78349ed80f24cb61ad05f997e97d805cc5b0409f.tar.gz
forums-78349ed80f24cb61ad05f997e97d805cc5b0409f.tar.bz2
forums-78349ed80f24cb61ad05f997e97d805cc5b0409f.tar.xz
forums-78349ed80f24cb61ad05f997e97d805cc5b0409f.zip
[ticket/14306] Automatically enable a safe mode when container building fails
PHPBB3-14306
-rw-r--r--phpBB/adm/style/overall_header.html20
-rw-r--r--phpBB/includes/functions_acp.php4
-rw-r--r--phpBB/phpbb/di/container_builder.php109
3 files changed, 77 insertions, 56 deletions
diff --git a/phpBB/adm/style/overall_header.html b/phpBB/adm/style/overall_header.html
index ada88edff2..dbf27eb942 100644
--- a/phpBB/adm/style/overall_header.html
+++ b/phpBB/adm/style/overall_header.html
@@ -49,7 +49,7 @@ function marklist(id, name, state)
}
var rb = parent.getElementsByTagName('input');
-
+
for (var r = 0; r < rb.length; r++)
{
if (rb[r].name.substr(0, name.length) == name)
@@ -103,7 +103,7 @@ function popup(url, width, height, name)
<p><a href="{U_ADM_INDEX}">{L_ADMIN_INDEX}</a> &bull; <a href="{U_INDEX}">{L_FORUM_INDEX}</a></p>
<p id="skip"><a href="#acp">{L_SKIP}</a></p>
</div>
-
+
<div id="page-body">
<div id="tabs">
<ul>
@@ -120,7 +120,7 @@ function popup(url, width, height, name)
<!-- DEFINE $LI_USED = 0 -->
<!-- BEGIN l_block1 -->
<!-- IF l_block1.S_SELECTED -->
-
+
<!-- BEGIN l_block2 -->
<!-- IF .l_block1.l_block2.l_block3 -->
<!-- IF $LI_USED --></ul></div><!-- ENDIF -->
@@ -129,13 +129,13 @@ function popup(url, width, height, name)
<ul>
<!-- DEFINE $LI_USED = 1 -->
<!-- ENDIF -->
-
+
<!-- BEGIN l_block3 -->
<li<!-- IF l_block1.l_block2.l_block3.S_SELECTED --> id="activemenu"<!-- ENDIF -->><a href="{l_block1.l_block2.l_block3.U_TITLE}"><span>{l_block1.l_block2.l_block3.L_TITLE}</span></a></li>
<!-- DEFINE $LI_USED = 1 -->
<!-- END l_block3 -->
<!-- END l_block2 -->
-
+
<!-- ENDIF -->
<!-- END l_block1 -->
<!-- IF $LI_USED -->
@@ -143,6 +143,14 @@ function popup(url, width, height, name)
</div>
<!-- ENDIF -->
</div>
-
+
<div id="main">
<div class="main">
+ <!-- IF CONTAINER_EXCEPTION !== false -->
+ <div class="errorbox">
+ <p>{L_CONTAINER_EXCEPTION}</p>
+ <p>{L_CONTAINER_EXCEPTION_DETAIL}</p>
+ <p>Exception message: {{ CONTAINER_EXCEPTION.getMessage() }}</p>
+ <pre>{{ CONTAINER_EXCEPTION.getTraceAsString() }}</pre>
+ </div>
+ <!-- ENDIF -->
diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php
index 4a52657023..803e4f5e54 100644
--- a/phpBB/includes/functions_acp.php
+++ b/phpBB/includes/functions_acp.php
@@ -26,7 +26,7 @@ function adm_page_header($page_title)
{
global $config, $db, $user, $template;
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $SID, $_SID;
- global $phpbb_dispatcher;
+ global $phpbb_dispatcher, $phpbb_container;
if (defined('HEADER_INC'))
{
@@ -105,6 +105,8 @@ function adm_page_header($page_title)
'S_CONTENT_ENCODING' => 'UTF-8',
'S_CONTENT_FLOW_BEGIN' => ($user->lang['DIRECTION'] == 'ltr') ? 'left' : 'right',
'S_CONTENT_FLOW_END' => ($user->lang['DIRECTION'] == 'ltr') ? 'right' : 'left',
+
+ 'CONTAINER_EXCEPTION' => $phpbb_container->hasParameter('container_exception') ? $phpbb_container->getParameter('container_exception') : false,
));
// An array of http headers that phpbb will set. The following event may override these.
diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php
index 8f175c966c..95d6483e34 100644
--- a/phpBB/phpbb/di/container_builder.php
+++ b/phpBB/phpbb/di/container_builder.php
@@ -90,7 +90,7 @@ class container_builder
*
* @var array
*/
- protected $custom_parameters = null;
+ protected $custom_parameters = [];
/**
* @var \phpbb\config_php_file
@@ -126,67 +126,80 @@ class container_builder
*/
public function get_container()
{
- $container_filename = $this->get_container_filename();
- $config_cache = new ConfigCache($container_filename, defined('DEBUG'));
- if ($this->use_cache && $config_cache->isFresh())
- {
- require($config_cache->getPath());
- $this->container = new \phpbb_cache_container();
- }
- else
- {
- $this->container_extensions = array(new extension\core($this->get_config_path()));
-
- if ($this->use_extensions)
+ try {
+ $container_filename = $this->get_container_filename();
+ $config_cache = new ConfigCache($container_filename, defined('DEBUG'));
+ if ($this->use_cache && $config_cache->isFresh())
{
- $this->load_extensions();
+ require($config_cache->getPath());
+ $this->container = new \phpbb_cache_container();
}
-
- // Inject the config
- if ($this->config_php_file)
+ else
{
- $this->container_extensions[] = new extension\config($this->config_php_file);
- }
+ $this->container_extensions = array(new extension\core($this->get_config_path()));
- $this->container = $this->create_container($this->container_extensions);
+ if ($this->use_extensions)
+ {
+ $this->load_extensions();
+ }
- // Easy collections through tags
- $this->container->addCompilerPass(new pass\collection_pass());
+ // Inject the config
+ if ($this->config_php_file)
+ {
+ $this->container_extensions[] = new extension\config($this->config_php_file);
+ }
- // Event listeners "phpBB style"
- $this->container->addCompilerPass(new RegisterListenersPass('dispatcher', 'event.listener_listener', 'event.listener'));
+ $this->container = $this->create_container($this->container_extensions);
- // Event listeners "Symfony style"
- $this->container->addCompilerPass(new RegisterListenersPass('dispatcher'));
+ // Easy collections through tags
+ $this->container->addCompilerPass(new pass\collection_pass());
- if ($this->use_extensions)
- {
- $this->register_ext_compiler_pass();
- }
+ // Event listeners "phpBB style"
+ $this->container->addCompilerPass(new RegisterListenersPass('dispatcher', 'event.listener_listener', 'event.listener'));
- $filesystem = new filesystem();
- $loader = new YamlFileLoader($this->container, new FileLocator($filesystem->realpath($this->get_config_path())));
- $loader->load($this->container->getParameter('core.environment') . '/config.yml');
+ // Event listeners "Symfony style"
+ $this->container->addCompilerPass(new RegisterListenersPass('dispatcher'));
- $this->inject_custom_parameters();
+ if ($this->use_extensions)
+ {
+ $this->register_ext_compiler_pass();
+ }
- if ($this->compile_container)
- {
- $this->container->compile();
+ $filesystem = new filesystem();
+ $loader = new YamlFileLoader($this->container, new FileLocator($filesystem->realpath($this->get_config_path())));
+ $loader->load($this->container->getParameter('core.environment') . '/config.yml');
- if ($this->use_cache)
+ $this->inject_custom_parameters();
+
+ if ($this->compile_container)
{
- $this->dump_container($config_cache);
+ $this->container->compile();
+
+ if ($this->use_cache)
+ {
+ $this->dump_container($config_cache);
+ }
}
}
- }
- if ($this->compile_container && $this->config_php_file)
+ if ($this->compile_container && $this->config_php_file)
+ {
+ $this->container->set('config.php', $this->config_php_file);
+ }
+
+ return $this->container;
+ }
+ catch (\Exception $e)
{
- $this->container->set('config.php', $this->config_php_file);
+ return $this
+ ->without_extensions()
+ ->without_cache()
+ ->with_custom_parameters(array_merge($this->custom_parameters, [
+ 'container_exception' => $e,
+ ]))
+ ->get_container()
+ ;
}
-
- return $this->container;
}
/**
@@ -451,13 +464,11 @@ class container_builder
*/
protected function inject_custom_parameters()
{
- if ($this->custom_parameters !== null)
+ foreach ($this->custom_parameters as $key => $value)
{
- foreach ($this->custom_parameters as $key => $value)
- {
- $this->container->setParameter($key, $value);
- }
+ $this->container->setParameter($key, $value);
}
+
}
/**