diff options
author | Maat <maat-pub@mageia.biz> | 2020-05-08 21:52:11 +0200 |
---|---|---|
committer | Maat <maat-pub@mageia.biz> | 2020-05-08 21:52:11 +0200 |
commit | 8ea437e30605e0f66b5220bf904a61d7c1d11ddd (patch) | |
tree | e0db2bb4a012d5b06a633160b19f62f4868ecd28 /phpBB/phpbb/event/kernel_exception_subscriber.php | |
parent | 36bc1870f21fac04736a1049c1d5b8e127d729f4 (diff) | |
parent | 2fdd46b36431ae0f58bb2e78e42553168db9a0ff (diff) | |
download | forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.gz forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.bz2 forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.xz forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.zip |
Merge remote-tracking branch 'upstream/prep-release-3.2.9'
Diffstat (limited to 'phpBB/phpbb/event/kernel_exception_subscriber.php')
-rw-r--r-- | phpBB/phpbb/event/kernel_exception_subscriber.php | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/phpBB/phpbb/event/kernel_exception_subscriber.php b/phpBB/phpbb/event/kernel_exception_subscriber.php index 1ee771cfe7..373e59b0c8 100644 --- a/phpBB/phpbb/event/kernel_exception_subscriber.php +++ b/phpBB/phpbb/event/kernel_exception_subscriber.php @@ -16,6 +16,7 @@ namespace phpbb\event; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpFoundation\Response; @@ -23,16 +24,25 @@ use Symfony\Component\HttpFoundation\Response; class kernel_exception_subscriber implements EventSubscriberInterface { /** + * Set to true to show full exception messages + * + * @var bool + */ + protected $debug; + + /** * Template object + * * @var \phpbb\template\template */ protected $template; /** - * User object - * @var \phpbb\user + * Language object + * + * @var \phpbb\language\language */ - protected $user; + protected $language; /** @var \phpbb\request\type_cast_helper */ protected $type_caster; @@ -40,13 +50,15 @@ class kernel_exception_subscriber implements EventSubscriberInterface /** * Construct method * - * @param \phpbb\template\template $template Template object - * @param \phpbb\user $user User object + * @param \phpbb\template\template $template Template 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\user $user) + public function __construct(\phpbb\template\template $template, \phpbb\language\language $language, $debug = false) { + $this->debug = $debug || defined('DEBUG'); $this->template = $template; - $this->user = $user; + $this->language = $language; $this->type_caster = new \phpbb\request\type_cast_helper(); } @@ -65,7 +77,11 @@ class kernel_exception_subscriber implements EventSubscriberInterface if ($exception instanceof \phpbb\exception\exception_interface) { - $message = call_user_func_array(array($this->user, 'lang'), array_merge(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 @@ -73,10 +89,10 @@ class kernel_exception_subscriber implements EventSubscriberInterface if (!$event->getRequest()->isXmlHttpRequest()) { - page_header($this->user->lang('INFORMATION')); + page_header($this->language->lang('INFORMATION')); $this->template->assign_vars(array( - 'MESSAGE_TITLE' => $this->user->lang('INFORMATION'), + 'MESSAGE_TITLE' => $this->language->lang('INFORMATION'), 'MESSAGE_TEXT' => $message, )); @@ -97,7 +113,7 @@ class kernel_exception_subscriber implements EventSubscriberInterface $data['message'] = $message; } - if (defined('DEBUG')) + if ($this->debug) { $data['trace'] = $exception->getTrace(); } @@ -114,7 +130,7 @@ class kernel_exception_subscriber implements EventSubscriberInterface $event->setResponse($response); } - public static function getSubscribedEvents() + static public function getSubscribedEvents() { return array( KernelEvents::EXCEPTION => 'on_kernel_exception', |