Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8483b48

Browse files
committed
bug #24244 TwigBundle exception/deprecation tweaks (ro0NL)
This PR was squashed before being merged into the 3.3 branch (closes #24244). Discussion ---------- TwigBundle exception/deprecation tweaks | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes/no | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!--highly recommended for new features--> - 1st commit) if you view a exception in the profiler, there is no logger available. Making the tab useless, disabled state is now triggered at zero log messages. There's a specialized panel here. - 2nd commit) when an exception occurs this highlights deprecations in the log table outside the profiler with a warning status. This follows the same signal colors in the profiler. - 3rd commit) hide the default inactive tabs from CSS to avoid scrollbar flickering. - 4th commit) favors document.DOMContentLoaded over window.load, we dont want to wait for images to be loaded Further out-of-scope improvements could be; - From #24191; i think the logs table should show a direct `View file` link for every error/deprecation/red or yellow line in here. Traversing with `Show context` is tedious. - links to file.php for your trigger_error() calls - links to config.yml for trigger_error() calls by SF - From #24151; having the same tooling on both sides is nice - Events/Translations logs is noise, we have specialized panels for those. To further reduce the overall page size container logs can be moved away too, linked from Configuration and/or Logs. Also see #23247 Commits ------- 1c595fc [TwigBundle][WebProfilerBundle] Switch to DOMContentLoaded event ea4b096 [WebProfilerBundle] Hide inactive tabs from CSS 0c10f97 [TwigBundle] Make deprecations scream in logs 03cd9e5 [TwigBundle] Hide logs if unavailable, i.e. webprofiler
2 parents beb3fe1 + 1c595fc commit 8483b48

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.html.twig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,15 @@
5454
</div>
5555
</div>
5656

57-
<div class="tab {{ logger is empty ? 'disabled' }}">
57+
{% if logger %}
58+
<div class="tab {{ logger.logs is empty ? 'disabled' }}">
5859
<h3 class="tab-title">
5960
Logs
6061
{% if logger.counterrors ?? false %}<span class="badge status-error">{{ logger.counterrors }}</span>{% endif %}
6162
</h3>
6263

6364
<div class="tab-content">
64-
{% if logger %}
65+
{% if logger.logs %}
6566
{{ include('@Twig/Exception/logs.html.twig', { logs: logger.logs }, with_context = false) }}
6667
{% else %}
6768
<div class="empty">
@@ -70,6 +71,7 @@
7071
{% endif %}
7172
</div>
7273
</div>
74+
{% endif %}
7375

7476
<div class="tab">
7577
<h3 class="tab-title">

src/Symfony/Bundle/TwigBundle/Resources/views/Exception/logs.html.twig

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@
1111

1212
<tbody>
1313
{% for log in logs %}
14-
<tr class="status-{{ log.priority >= 400 ? 'error' : log.priority >= 300 ? 'warning' : 'normal' }}">
14+
{% if log.priority >= 400 %}
15+
{% set status = 'error' %}
16+
{% elseif log.priority >= 300 %}
17+
{% set status = 'warning' %}
18+
{% else %}
19+
{% set severity = log.context.exception.severity|default(false) %}
20+
{% set status = severity is constant('E_DEPRECATED') or severity is constant('E_USER_DEPRECATED') ? 'warning' : 'normal' %}
21+
{% endif %}
22+
<tr class="status-{{ status }}">
1523
<td class="text-small" nowrap>
1624
<span class="colored text-bold">{{ log.priorityName }}</span>
1725
<span class="text-muted newline">{{ log.timestamp|date('H:i:s') }}</span>

src/Symfony/Bundle/TwigBundle/Resources/views/base_js.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
};
170170
})();
171171
172-
Sfjs.addEventListener(window, 'load', function() {
172+
Sfjs.addEventListener(document, 'DOMContentLoaded', function() {
173173
Sfjs.createTabs();
174174
Sfjs.createToggles();
175175
});

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@
523523
};
524524
})();
525525
526-
Sfjs.addEventListener(window, 'load', function() {
526+
Sfjs.addEventListener(document, 'DOMContentLoaded', function() {
527527
Sfjs.createTabs();
528528
Sfjs.createToggles();
529529
});

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,8 @@ tr.status-warning td {
832832
.tab-navigation li .badge.status-warning { background: {{ colors.warning|raw }}; color: #FFF; }
833833
.tab-navigation li .badge.status-error { background: {{ colors.error|raw }}; color: #FFF; }
834834

835+
.sf-tabs .tab:not(:first-child) { display: none; }
836+
835837
{# Toggles
836838
========================================================================= #}
837839
.sf-toggle-content {

0 commit comments

Comments
 (0)