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 326aa86

Browse filesBrowse files
linaorifabpot
authored andcommitted
Show more accurate message in profiler when missing stopwatch
1 parent a292740 commit 326aa86
Copy full SHA for 326aa86

File tree

4 files changed

+17
-2
lines changed
Filter options

4 files changed

+17
-2
lines changed

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@
9595

9696
<h2>Execution timeline</h2>
9797

98-
{% if collector.events is empty %}
98+
{% if not collector.isStopwatchInstalled() %}
99+
<div class="empty">
100+
<p>The Stopwatch component is not installed. If you want to see timing events, run: <code>composer require symfony/stopwatch</code>.</p>
101+
</div>
102+
{% elseif collector.events is empty %}
99103
<div class="empty">
100104
<p>No timing events have been recorded. Are you sure that debugging is enabled in the kernel?</p>
101105
</div>

‎src/Symfony/Bundle/WebProfilerBundle/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"require": {
1919
"php": "^5.5.9|>=7.0.8",
20-
"symfony/http-kernel": "~3.3|~4.0",
20+
"symfony/http-kernel": "~3.4.25|^4.2.6",
2121
"symfony/polyfill-php70": "~1.0",
2222
"symfony/routing": "~2.8|~3.0|~4.0",
2323
"symfony/twig-bridge": "~2.8|~3.0|~4.0",

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public function collect(Request $request, Response $response, \Exception $except
4747
'token' => $response->headers->get('X-Debug-Token'),
4848
'start_time' => $startTime * 1000,
4949
'events' => [],
50+
'stopwatch_installed' => \class_exists(Stopwatch::class, false),
5051
];
5152
}
5253

@@ -139,6 +140,14 @@ public function getStartTime()
139140
return $this->data['start_time'];
140141
}
141142

143+
/**
144+
* @return bool whether or not the stopwatch component is installed
145+
*/
146+
public function isStopwatchInstalled()
147+
{
148+
return $this->data['stopwatch_installed'];
149+
}
150+
142151
/**
143152
* {@inheritdoc}
144153
*/

‎src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\HttpFoundation\Response;
1717
use Symfony\Component\HttpKernel\DataCollector\TimeDataCollector;
18+
use Symfony\Component\Stopwatch\Stopwatch;
1819

1920
/**
2021
* @group time-sensitive
@@ -51,5 +52,6 @@ public function testCollect()
5152

5253
$c->collect($request, new Response());
5354
$this->assertEquals(123456000, $c->getStartTime());
55+
$this->assertSame(\class_exists(Stopwatch::class, false), $c->isStopwatchInstalled());
5456
}
5557
}

0 commit comments

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