mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
[ticket/14306] Automatically enable a safe mode when container building fails
PHPBB3-14306
This commit is contained in:
parent
f6524f4902
commit
78349ed80f
3 changed files with 85 additions and 64 deletions
|
@ -146,3 +146,11 @@ function popup(url, width, height, name)
|
||||||
|
|
||||||
<div id="main">
|
<div id="main">
|
||||||
<div class="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 -->
|
||||||
|
|
|
@ -26,7 +26,7 @@ function adm_page_header($page_title)
|
||||||
{
|
{
|
||||||
global $config, $db, $user, $template;
|
global $config, $db, $user, $template;
|
||||||
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $SID, $_SID;
|
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $SID, $_SID;
|
||||||
global $phpbb_dispatcher;
|
global $phpbb_dispatcher, $phpbb_container;
|
||||||
|
|
||||||
if (defined('HEADER_INC'))
|
if (defined('HEADER_INC'))
|
||||||
{
|
{
|
||||||
|
@ -105,6 +105,8 @@ function adm_page_header($page_title)
|
||||||
'S_CONTENT_ENCODING' => 'UTF-8',
|
'S_CONTENT_ENCODING' => 'UTF-8',
|
||||||
'S_CONTENT_FLOW_BEGIN' => ($user->lang['DIRECTION'] == 'ltr') ? 'left' : 'right',
|
'S_CONTENT_FLOW_BEGIN' => ($user->lang['DIRECTION'] == 'ltr') ? 'left' : 'right',
|
||||||
'S_CONTENT_FLOW_END' => ($user->lang['DIRECTION'] == 'ltr') ? 'right' : 'left',
|
'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.
|
// An array of http headers that phpbb will set. The following event may override these.
|
||||||
|
|
|
@ -90,7 +90,7 @@ class container_builder
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $custom_parameters = null;
|
protected $custom_parameters = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \phpbb\config_php_file
|
* @var \phpbb\config_php_file
|
||||||
|
@ -126,6 +126,7 @@ class container_builder
|
||||||
*/
|
*/
|
||||||
public function get_container()
|
public function get_container()
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
$container_filename = $this->get_container_filename();
|
$container_filename = $this->get_container_filename();
|
||||||
$config_cache = new ConfigCache($container_filename, defined('DEBUG'));
|
$config_cache = new ConfigCache($container_filename, defined('DEBUG'));
|
||||||
if ($this->use_cache && $config_cache->isFresh())
|
if ($this->use_cache && $config_cache->isFresh())
|
||||||
|
@ -188,6 +189,18 @@ class container_builder
|
||||||
|
|
||||||
return $this->container;
|
return $this->container;
|
||||||
}
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
return $this
|
||||||
|
->without_extensions()
|
||||||
|
->without_cache()
|
||||||
|
->with_custom_parameters(array_merge($this->custom_parameters, [
|
||||||
|
'container_exception' => $e,
|
||||||
|
]))
|
||||||
|
->get_container()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable the extensions.
|
* Enable the extensions.
|
||||||
|
@ -450,14 +463,12 @@ class container_builder
|
||||||
* Inject the customs parameters into the container
|
* Inject the customs parameters into the container
|
||||||
*/
|
*/
|
||||||
protected function inject_custom_parameters()
|
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);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue