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

Appearance settings

Commit e7426ca

Browse filesBrowse files
committed
[Stopwatch] fix wrong nullable type
1 parent 44e6250 commit e7426ca
Copy full SHA for e7426ca

File tree

Expand file treeCollapse file tree

5 files changed

+17
-5
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+17
-5
lines changed

‎UPGRADE-5.0.md

Copy file name to clipboardExpand all lines: UPGRADE-5.0.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ Serializer
480480
Stopwatch
481481
---------
482482

483-
* Removed support of passing `null` as 1st (`$id`) argument of `Section::get()` method, pass a valid child section identifier instead.
483+
* Removed support for passing `null` as 1st (`$id`) argument of `Section::get()` method, pass a valid child section identifier instead.
484484

485485
Translation
486486
-----------

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ protected function beforeDispatch(string $eventName, $event)
4141
break;
4242
case KernelEvents::TERMINATE:
4343
$token = $event->getResponse()->headers->get('X-Debug-Token');
44+
if (null === $token) {
45+
break;
46+
}
4447
// There is a very special case when using built-in AppCache class as kernel wrapper, in the case
4548
// of an ESI request leading to a `stale` response [B] inside a `fresh` cached response [A].
4649
// In this case, `$token` contains the [B] debug token, but the open `stopwatch` section ID
@@ -65,12 +68,18 @@ protected function afterDispatch(string $eventName, $event)
6568
break;
6669
case KernelEvents::RESPONSE:
6770
$token = $event->getResponse()->headers->get('X-Debug-Token');
71+
if (null === $token) {
72+
break;
73+
}
6874
$this->stopwatch->stopSection($token);
6975
break;
7076
case KernelEvents::TERMINATE:
7177
// In the special case described in the `preDispatch` method above, the `$token` section
7278
// does not exist, then closing it throws an exception which must be caught.
7379
$token = $event->getResponse()->headers->get('X-Debug-Token');
80+
if (null === $token) {
81+
break;
82+
}
7483
try {
7584
$this->stopwatch->stopSection($token);
7685
} catch (\LogicException $e) {

‎src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,13 @@ public function testStopwatchCheckControllerOnRequestEvent()
6262
public function testStopwatchStopControllerOnRequestEvent()
6363
{
6464
$stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')
65-
->setMethods(['isStarted', 'stop', 'stopSection'])
65+
->setMethods(['isStarted', 'stop'])
6666
->getMock();
6767
$stopwatch->expects($this->once())
6868
->method('isStarted')
6969
->willReturn(true);
7070
$stopwatch->expects($this->once())
7171
->method('stop');
72-
$stopwatch->expects($this->once())
73-
->method('stopSection');
7472

7573
$dispatcher = new TraceableEventDispatcher(new EventDispatcher(), $stopwatch);
7674

‎src/Symfony/Component/Stopwatch/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Stopwatch/CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
5.0.0
5+
-----
6+
7+
* Removed support for passing `null` as 1st (`$id`) argument of `Section::get()` method, pass a valid child section identifier instead.
8+
49
4.4.0
510
-----
611

‎src/Symfony/Component/Stopwatch/Stopwatch.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Stopwatch/Stopwatch.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function openSection(string $id = null)
8181
*
8282
* @throws \LogicException When there's no started section to be stopped
8383
*/
84-
public function stopSection(?string $id)
84+
public function stopSection(string $id)
8585
{
8686
$this->stop('__section__');
8787

0 commit comments

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