mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
Merge branch '3.2.x'
This commit is contained in:
commit
10f487fbf6
3 changed files with 18 additions and 2 deletions
|
@ -9,6 +9,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
- '@template'
|
- '@template'
|
||||||
- '@language'
|
- '@language'
|
||||||
|
- '%debug.exceptions%'
|
||||||
tags:
|
tags:
|
||||||
- { name: kernel.event_subscriber }
|
- { name: kernel.event_subscriber }
|
||||||
|
|
||||||
|
|
|
@ -557,6 +557,7 @@ $lang = array_merge($lang, array(
|
||||||
),
|
),
|
||||||
'OPTIONS' => 'Options',
|
'OPTIONS' => 'Options',
|
||||||
|
|
||||||
|
'PAGE_NOT_FOUND' => 'The requested page could not be found.',
|
||||||
'PAGE_OF' => 'Page <strong>%1$d</strong> of <strong>%2$d</strong>',
|
'PAGE_OF' => 'Page <strong>%1$d</strong> of <strong>%2$d</strong>',
|
||||||
'PAGE_TITLE_NUMBER' => 'Page %s',
|
'PAGE_TITLE_NUMBER' => 'Page %s',
|
||||||
'PASSWORD' => 'Password',
|
'PASSWORD' => 'Password',
|
||||||
|
|
|
@ -16,12 +16,20 @@ namespace phpbb\event;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use Symfony\Component\HttpKernel\KernelEvents;
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class kernel_exception_subscriber implements EventSubscriberInterface
|
class kernel_exception_subscriber implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Set to true to show full exception messages
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $debug;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Template object
|
* Template object
|
||||||
*
|
*
|
||||||
|
@ -44,9 +52,11 @@ class kernel_exception_subscriber implements EventSubscriberInterface
|
||||||
*
|
*
|
||||||
* @param \phpbb\template\template $template Template object
|
* @param \phpbb\template\template $template Template object
|
||||||
* @param \phpbb\language\language $language Language object
|
* @param \phpbb\language\language $language Language object
|
||||||
|
* @param bool $debug Set to true to show full exception messages
|
||||||
*/
|
*/
|
||||||
public function __construct(\phpbb\template\template $template, \phpbb\language\language $language)
|
public function __construct(\phpbb\template\template $template, \phpbb\language\language $language, $debug = false)
|
||||||
{
|
{
|
||||||
|
$this->debug = $debug || defined('DEBUG');
|
||||||
$this->template = $template;
|
$this->template = $template;
|
||||||
$this->language = $language;
|
$this->language = $language;
|
||||||
$this->type_caster = new \phpbb\request\type_cast_helper();
|
$this->type_caster = new \phpbb\request\type_cast_helper();
|
||||||
|
@ -69,6 +79,10 @@ class kernel_exception_subscriber implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
$message = $this->language->lang_array($message, $exception->get_parameters());
|
$message = $this->language->lang_array($message, $exception->get_parameters());
|
||||||
}
|
}
|
||||||
|
else if (!$this->debug && $exception instanceof NotFoundHttpException)
|
||||||
|
{
|
||||||
|
$message = $this->language->lang('PAGE_NOT_FOUND');
|
||||||
|
}
|
||||||
|
|
||||||
// Show <strong> text in bold
|
// Show <strong> text in bold
|
||||||
$message = preg_replace('#<(/?strong)>#i', '<$1>', $message);
|
$message = preg_replace('#<(/?strong)>#i', '<$1>', $message);
|
||||||
|
@ -99,7 +113,7 @@ class kernel_exception_subscriber implements EventSubscriberInterface
|
||||||
$data['message'] = $message;
|
$data['message'] = $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined('DEBUG'))
|
if ($this->debug)
|
||||||
{
|
{
|
||||||
$data['trace'] = $exception->getTrace();
|
$data['trace'] = $exception->getTrace();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue