1616use Symfony \Component \EventDispatcher \EventSubscriberInterface ;
1717use Symfony \Component \HttpFoundation \JsonResponse ;
1818use Symfony \Component \HttpKernel \Exception \HttpExceptionInterface ;
19+ use Symfony \Component \HttpKernel \Exception \NotFoundHttpException ;
1920use Symfony \Component \HttpKernel \KernelEvents ;
2021use Symfony \Component \HttpKernel \Event \GetResponseForExceptionEvent ;
2122use Symfony \Component \HttpFoundation \Response ;
2223
2324class kernel_exception_subscriber implements EventSubscriberInterface
2425{
26+ /**
27+ * Set to true to show full exception messages
28+ *
29+ * @var bool
30+ */
31+ protected $ debug ;
32+
2533 /**
2634 * Template object
2735 *
@@ -45,8 +53,9 @@ class kernel_exception_subscriber implements EventSubscriberInterface
4553 * @param \phpbb\template\template $template Template object
4654 * @param \phpbb\language\language $language Language object
4755 */
48- public function __construct (\phpbb \template \template $ template , \phpbb \language \language $ language )
56+ public function __construct (\phpbb \template \template $ template , \phpbb \language \language $ language, $ debug = false )
4957 {
58+ $ this ->debug = $ debug || defined ('DEBUG ' );
5059 $ this ->template = $ template ;
5160 $ this ->language = $ language ;
5261 $ this ->type_caster = new \phpbb \request \type_cast_helper ();
@@ -69,6 +78,10 @@ public function on_kernel_exception(GetResponseForExceptionEvent $event)
6978 {
7079 $ message = $ this ->language ->lang_array ($ message , $ exception ->get_parameters ());
7180 }
81+ else if (!$ this ->debug && $ exception instanceof NotFoundHttpException)
82+ {
83+ $ message = $ this ->language ->lang ('PAGE_NOT_FOUND ' );
84+ }
7285
7386 // Show <strong> text in bold
7487 $ message = preg_replace ('#<(/?strong)>#i ' , '<$1> ' , $ message );
@@ -99,7 +112,7 @@ public function on_kernel_exception(GetResponseForExceptionEvent $event)
99112 $ data ['message ' ] = $ message ;
100113 }
101114
102- if (defined ( ' DEBUG ' ) )
115+ if ($ this -> debug )
103116 {
104117 $ data ['trace ' ] = $ exception ->getTrace ();
105118 }
0 commit comments