Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
Appearance settings

Commitc9dfb2d

Browse files
Other solution
1 parent173c053 commitc9dfb2d

File tree

7 files changed

+13
-54
lines changed

7 files changed

+13
-54
lines changed

‎src/Symfony/Component/HttpKernel/Event/ExceptionEvent.php‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ final class ExceptionEvent extends RequestEvent
3131
{
3232
private\Throwable$throwable;
3333
privatebool$allowCustomResponseCode =false;
34+
privatebool$isKernelTerminated =false;
3435

35-
publicfunction__construct(HttpKernelInterface$kernel,Request$request,int$requestType,\Throwable$e)
36+
publicfunction__construct(HttpKernelInterface$kernel,Request$request,int$requestType,\Throwable$e,bool$isKernelTerminated =false)
3637
{
3738
parent::__construct($kernel,$request,$requestType);
3839

3940
$this->setThrowable($e);
41+
$this->isKernelTerminated =false;
4042
}
4143

4244
publicfunctiongetThrowable():\Throwable
@@ -69,4 +71,9 @@ public function isAllowingCustomResponseCode(): bool
6971
{
7072
return$this->allowCustomResponseCode;
7173
}
74+
75+
publicfunctionisKernelTerminated():bool
76+
{
77+
return$this->isKernelTerminated;
78+
}
7279
}

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
useSymfony\Component\HttpKernel\HttpKernelInterface;
2828
useSymfony\Component\HttpKernel\KernelEvents;
2929
useSymfony\Component\HttpKernel\Log\DebugLoggerConfigurator;
30-
useSymfony\Component\HttpKernel\TerminableInterface;
3130

3231
/**
3332
* @author Fabien Potencier <fabien@symfony.com>
@@ -105,9 +104,7 @@ public function onKernelException(ExceptionEvent $event)
105104

106105
if (
107106
!$this->debug
108-
&&$event->getKernel()instanceof TerminableInterface
109-
&&method_exists($event->getKernel(),'isTerminated')
110-
&&$event->getKernel()->isTerminated()
107+
&&$event->isKernelTerminated()
111108
) {
112109
return;
113110
}

‎src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -261,18 +261,6 @@ public function terminate(Request $request, Response $response)
261261
}
262262
}
263263

264-
publicfunctionisTerminated():bool
265-
{
266-
if (
267-
$this->getKernel()instanceof TerminableInterface
268-
&&method_exists($this->getKernel(),'isTerminated')
269-
) {
270-
return$this->getKernel()->isTerminated();
271-
}
272-
273-
returnfalse;
274-
}
275-
276264
/**
277265
* Forwards the Request to the backend without storing the Response in the cache.
278266
*

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,6 @@ public function terminate(Request $request, Response $response)
117117
$this->dispatcher->dispatch(newTerminateEvent($this,$request,$response), KernelEvents::TERMINATE);
118118
}
119119

120-
publicfunctionisTerminated():bool
121-
{
122-
return$this->terminated;
123-
}
124-
125120
/**
126121
* @internal
127122
*/
@@ -242,7 +237,7 @@ private function finishRequest(Request $request, int $type): void
242237
*/
243238
privatefunctionhandleThrowable(\Throwable$e,Request$request,int$type):Response
244239
{
245-
$event =newExceptionEvent($this,$request,$type,$e);
240+
$event =newExceptionEvent($this,$request,$type,$e,$this->terminated);
246241
$this->dispatcher->dispatch($event, KernelEvents::EXCEPTION);
247242

248243
// a listener might have replaced the exception

‎src/Symfony/Component/HttpKernel/Kernel.php‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -158,18 +158,6 @@ public function terminate(Request $request, Response $response)
158158
}
159159
}
160160

161-
publicfunctionisTerminated():bool
162-
{
163-
if (
164-
$this->getHttpKernel()instanceof TerminableInterface
165-
&&method_exists($this->getHttpKernel(),'isTerminated')
166-
) {
167-
return$this->getHttpKernel()->isTerminated();
168-
}
169-
170-
returnfalse;
171-
}
172-
173161
/**
174162
* @return void
175163
*/

‎src/Symfony/Component/HttpKernel/TerminableInterface.php‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
*
2121
* @author Jordi Boggiano <j.boggiano@seld.be>
2222
* @author Pierre Minnieur <pierre.minnieur@sensiolabs.de>
23-
*
24-
* @method bool isTerminated()
2523
*/
2624
interface TerminableInterface
2725
{

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

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
useSymfony\Component\HttpKernel\HttpKernelInterface;
3030
useSymfony\Component\HttpKernel\KernelEvents;
3131
useSymfony\Component\HttpKernel\Log\DebugLoggerInterface;
32-
useSymfony\Component\HttpKernel\TerminableInterface;
3332
useSymfony\Component\HttpKernel\Tests\Logger;
3433

3534
/**
@@ -249,13 +248,12 @@ public function testTerminated()
249248
{
250249
$listener =newErrorListener('foo',$this->createMock(LoggerInterface::class));
251250

252-
$kernel =$this->createPartialMock(TestKernel::class, ['handle']);
251+
$kernel =$this->createMock(HttpKernelInterface::class);
253252
$kernel->expects($this->never())->method('handle');
254253

255254
$request = Request::create('/');
256-
$kernel->terminate($request,newResponse());
257255

258-
$event =newExceptionEvent($kernel,$request, HttpKernelInterface::MAIN_REQUEST,new \Exception('foo'));
256+
$event =newExceptionEvent($kernel,$request, HttpKernelInterface::MAIN_REQUEST,new \Exception('foo'),true);
259257
$listener->onKernelException($event);
260258
}
261259

@@ -311,10 +309,8 @@ public function countErrors(Request $request = null): int
311309
}
312310
}
313311

314-
class TestKernelimplements HttpKernelInterface, TerminableInterface
312+
class TestKernelimplements HttpKernelInterface
315313
{
316-
privatebool$terminated =false;
317-
318314
publicfunctionhandle(Request$request,$type =self::MAIN_REQUEST,$catch =true):Response
319315
{
320316
$e =$request->attributes->get('exception');
@@ -324,16 +320,6 @@ public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = tr
324320

325321
returnnewResponse('foo');
326322
}
327-
328-
publicfunctionisTerminated():bool
329-
{
330-
return$this->terminated;
331-
}
332-
333-
publicfunctionterminate(Request$request,Response$response):void
334-
{
335-
$this->terminated =true;
336-
}
337323
}
338324

339325
class TestKernelThatThrowsExceptionimplements HttpKernelInterface

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp