From 410b597393efc5fd5586c7a24fc7fb5ffca64331 Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 17 Dec 2017 16:53:26 +0100 Subject: [PATCH] Fix panel break when stopwatch component is not installed. --- .../Resources/views/Collector/time.html.twig | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig index 28e3a3c838..2e8207e757 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig @@ -14,10 +14,12 @@ } %} {% endif %} +{% set has_time_events = collector.events|length > 0 %} + {% block toolbar %} - {% set total_time = collector.events|length ? '%.0f'|format(collector.duration) : 'n/a' %} + {% set total_time = has_time_events ? '%.0f'|format(collector.duration) : 'n/a' %} {% set initialization_time = collector.events|length ? '%.0f'|format(collector.inittime) : 'n/a' %} - {% set status_color = collector.events|length and collector.duration > 1000 ? 'yellow' : '' %} + {% set status_color = has_time_events and collector.duration > 1000 ? 'yellow' : '' %} {% set icon %} {{ include('@WebProfiler/Icon/time.svg') }} @@ -75,10 +77,14 @@ Sub-Request{{ profile.children|length > 1 ? 's' }} - {% set subrequests_time = 0 %} - {% for child in profile.children %} - {% set subrequests_time = subrequests_time + child.getcollector('time').events.__section__.duration %} - {% endfor %} + {% if has_time_events %} + {% set subrequests_time = 0 %} + {% for child in profile.children %} + {% set subrequests_time = subrequests_time + child.getcollector('time').events.__section__.duration %} + {% endfor %} + {% else %} + {% set subrequests_time = 0 %} + {% endif %}
{{ subrequests_time }} ms