Skip to content

Commit ae6f668

Browse files
committed
bug symfony#25526 [WebProfilerBundle] Fix panel break when stopwatch component is not installed. (umulmrum, javiereguiluz)
This PR was merged into the 3.4 branch. Discussion ---------- [WebProfilerBundle] Fix panel break when stopwatch component is not installed. | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#25350 | License | MIT | Doc PR | - Fixes a crash in the time profiler panel when the stopwatch is not installed. This avoids a hard dependency like the ticket author requested, as the rest of the component can already deal with that case. I think this is an issue in 3.4+, but I only tested against 4.0.2 locally (code in the affected file only differs in whitespace between 3.4 and 4.0). Commits ------- e9577cb Display n/a for sub-requests time when Stopwatch component is not installed 410b597 Fix panel break when stopwatch component is not installed.
2 parents 02524ee + e9577cb commit ae6f668

File tree

1 file changed

+12
-6
lines changed
  • src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector

1 file changed

+12
-6
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
} %}
1515
{% endif %}
1616

17+
{% set has_time_events = collector.events|length > 0 %}
18+
1719
{% block toolbar %}
18-
{% set total_time = collector.events|length ? '%.0f'|format(collector.duration) : 'n/a' %}
20+
{% set total_time = has_time_events ? '%.0f'|format(collector.duration) : 'n/a' %}
1921
{% set initialization_time = collector.events|length ? '%.0f'|format(collector.inittime) : 'n/a' %}
20-
{% set status_color = collector.events|length and collector.duration > 1000 ? 'yellow' : '' %}
22+
{% set status_color = has_time_events and collector.duration > 1000 ? 'yellow' : '' %}
2123

2224
{% set icon %}
2325
{{ include('@WebProfiler/Icon/time.svg') }}
@@ -75,10 +77,14 @@
7577
<span class="label">Sub-Request{{ profile.children|length > 1 ? 's' }}</span>
7678
</div>
7779

78-
{% set subrequests_time = 0 %}
79-
{% for child in profile.children %}
80-
{% set subrequests_time = subrequests_time + child.getcollector('time').events.__section__.duration %}
81-
{% endfor %}
80+
{% if has_time_events %}
81+
{% set subrequests_time = 0 %}
82+
{% for child in profile.children %}
83+
{% set subrequests_time = subrequests_time + child.getcollector('time').events.__section__.duration %}
84+
{% endfor %}
85+
{% else %}
86+
{% set subrequests_time = 'n/a' %}
87+
{% endif %}
8288

8389
<div class="metric">
8490
<span class="value">{{ subrequests_time }} <span class="unit">ms</span></span>

0 commit comments

Comments
 (0)