Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c6acad7

Browse filesBrowse files
Revert "bug #26138 [HttpKernel] Catch HttpExceptions when templating is not installed (cilefen)"
This reverts commit b213c5a, reversing changes made to 61af0e3.
1 parent 9a077ca commit c6acad7
Copy full SHA for c6acad7

File tree

3 files changed

+3
-40
lines changed
Filter options

3 files changed

+3
-40
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml
-10Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,6 @@
6767
<argument type="service" id="router" on-invalid="ignore" />
6868
</service>
6969

70-
<service id="http_exception_listener" class="Symfony\Component\HttpKernel\EventListener\ExceptionListener">
71-
<tag name="kernel.event_listener" event="kernel.exception" method="onKernelException" priority="-256"/>
72-
<tag name="monolog.logger" channel="request" />
73-
<argument>null</argument>
74-
<argument type="service" id="logger" on-invalid="null" />
75-
<argument>%kernel.debug%</argument>
76-
<argument>%kernel.charset%</argument>
77-
<argument>%debug.file_link_format%</argument>
78-
</service>
79-
8070
<service id="validate_request_listener" class="Symfony\Component\HttpKernel\EventListener\ValidateRequestListener">
8171
<tag name="kernel.event_subscriber" />
8272
</service>

‎src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php
+3-13Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
namespace Symfony\Component\HttpKernel\EventListener;
1313

1414
use Psr\Log\LoggerInterface;
15-
use Symfony\Component\Debug\ExceptionHandler;
1615
use Symfony\Component\Debug\Exception\FlattenException;
1716
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
1817
use Symfony\Component\HttpFoundation\Request;
19-
use Symfony\Component\HttpFoundation\Response;
2018
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
2119
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
2220
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
@@ -35,16 +33,12 @@ class ExceptionListener implements EventSubscriberInterface
3533
protected $controller;
3634
protected $logger;
3735
protected $debug;
38-
private $charset;
39-
private $fileLinkFormat;
4036

41-
public function __construct($controller, LoggerInterface $logger = null, $debug = false, $charset = null, $fileLinkFormat = null)
37+
public function __construct($controller, LoggerInterface $logger = null, $debug = false)
4238
{
4339
$this->controller = $controller;
4440
$this->logger = $logger;
4541
$this->debug = $debug;
46-
$this->charset = $charset;
47-
$this->fileLinkFormat = $fileLinkFormat;
4842
}
4943

5044
public function onKernelException(GetResponseForExceptionEvent $event)
@@ -123,12 +117,8 @@ protected function logException(\Exception $exception, $message)
123117
protected function duplicateRequest(\Exception $exception, Request $request)
124118
{
125119
$attributes = array(
126-
'exception' => $exception = FlattenException::create($exception),
127-
'_controller' => $this->controller ?: function () use ($exception) {
128-
$handler = new ExceptionHandler($this->debug, $this->charset, $this->fileLinkFormat);
129-
130-
return new Response($handler->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders());
131-
},
120+
'_controller' => $this->controller,
121+
'exception' => FlattenException::create($exception),
132122
'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null,
133123
);
134124
$request = $request->duplicate(null, null, $attributes);

‎src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php
-17Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -151,23 +151,6 @@ public function testCSPHeaderIsRemoved()
151151
$this->assertFalse($response->headers->has('content-security-policy'), 'CSP header has been removed');
152152
$this->assertFalse($dispatcher->hasListeners(KernelEvents::RESPONSE), 'CSP removal listener has been removed');
153153
}
154-
155-
public function testNullController()
156-
{
157-
$listener = new ExceptionListener(null);
158-
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
159-
$kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) {
160-
$controller = $request->attributes->get('_controller');
161-
162-
return $controller();
163-
}));
164-
$request = Request::create('/');
165-
$event = new GetResponseForExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new \Exception('foo'));
166-
167-
$listener->onKernelException($event);
168-
169-
$this->assertContains('Whoops, looks like something went wrong.', $event->getResponse()->getContent());
170-
}
171154
}
172155

173156
class TestLogger extends Logger implements DebugLoggerInterface

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.