diff --git a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php
index 79dd9938b6c05..5bc383d5f5483 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 f69406475a2af..747d73f5de8c4 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 58e1fe355621f..ba94bc0eff6b1 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 %}
-
-
- {{ filename|file_excerpt(line, -1) }}
-
+ {% set source = filename|file_excerpt(line, -1) %}
+
+
+ {% if source is null %}
+
The file is not readable.
+ {% else %}
+ {{ source|raw }}
+ {% endif %}
+
{% endblock %}