diff --git a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php index 79dd9938b6c0..5bc383d5f548 100644 --- a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php @@ -134,7 +134,7 @@ public function formatArgsAsText($args) */ public function fileExcerpt($file, $line, $srcContext = 3) { - if (is_readable($file)) { + if (is_file($file) && is_readable($file)) { // highlight_file could throw warnings // see https://bugs.php.net/bug.php?id=25725 $code = @highlight_file($file, true); @@ -157,6 +157,8 @@ public function fileExcerpt($file, $line, $srcContext = 3) return '
    '.implode("\n", $lines).'
'; } + + return null; } /** diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/open.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/open.css.twig index f69406475a2a..747d73f5de8c 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/open.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/open.css.twig @@ -54,6 +54,11 @@ a.doc:hover { text-decoration: underline; } +.empty { + padding: 10px; + color: #555; +} + .source { margin-top: 41px; } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/open.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/open.html.twig index 58e1fe355621..ba94bc0eff6b 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/open.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/open.html.twig @@ -7,11 +7,16 @@ {% endblock %} {% block body %} -
-

{{ file }}{% if 0 < line %} line {{ line }}{% endif %}

- Open in your IDE? -
-
- {{ filename|file_excerpt(line, -1) }} -
+ {% set source = filename|file_excerpt(line, -1) %} +
+

{{ file }}{% if 0 < line %} line {{ line }}{% endif %}

+ Open in your IDE? +
+
+ {% if source is null %} +

The file is not readable.

+ {% else %} + {{ source|raw }} + {% endif %} +
{% endblock %}