Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Debug][WebProfilerBundle] Fix setting file link format #27074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 30, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[Debug][WebProfilerBundle] Fix setting file link format
  • Loading branch information
nicolas-grekas committed Apr 30, 2018
commit a4a1645d4475f08e08c54bec91184d8d1e061c2f
4 changes: 3 additions & 1 deletion 4 src/Symfony/Bridge/Twig/Extension/CodeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ public function formatFile($file, $line, $text = null)
}
}

$text = "$text at line $line";
if (0 < $line) {
$text .= ' at line '.$line;
}

if (false !== $link = $this->getFileLink($file, $line)) {
return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, ENT_COMPAT | ENT_SUBSTITUTE, $this->charset), $text);
Expand Down
3 changes: 3 additions & 0 deletions 3 src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class FrameworkBundle extends Bundle
{
public function boot()
{
if (!ini_get('xdebug.file_link_format') && !get_cfg_var('xdebug.file_link_format')) {
ini_set('xdebug.file_link_format', $this->container->getParameter('debug.file_link_format'));
}
ErrorHandler::register(null, false)->throwAt($this->container->getParameter('debug.error_handler.throw_at'), true);

if ($this->container->hasParameter('kernel.trusted_proxies')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Bundle\WebProfilerBundle\Controller;

use Symfony\Component\HttpKernel\Debug\FileLinkFormatter;
use Symfony\Component\HttpKernel\Profiler\Profiler;
use Symfony\Component\Debug\ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
Expand All @@ -30,11 +31,12 @@ class ExceptionController
protected $debug;
protected $profiler;

public function __construct(Profiler $profiler = null, Environment $twig, $debug)
public function __construct(Profiler $profiler = null, Environment $twig, $debug, FileLinkFormatter $fileLinkFormat = null)
{
$this->profiler = $profiler;
$this->twig = $twig;
$this->debug = $debug;
$this->fileLinkFormat = $fileLinkFormat;
}

/**
Expand All @@ -58,7 +60,7 @@ public function showAction($token)
$template = $this->getTemplate();

if (!$this->twig->getLoader()->exists($template)) {
$handler = new ExceptionHandler($this->debug, $this->twig->getCharset());
$handler = new ExceptionHandler($this->debug, $this->twig->getCharset(), $this->fileLinkFormat);

return new Response($handler->getContent($exception), 200, array('Content-Type' => 'text/html'));
}
Expand Down Expand Up @@ -98,7 +100,7 @@ public function cssAction($token)
$template = $this->getTemplate();

if (!$this->templateExists($template)) {
$handler = new ExceptionHandler($this->debug, $this->twig->getCharset());
$handler = new ExceptionHandler($this->debug, $this->twig->getCharset(), $this->fileLinkFormat);

return new Response($handler->getStylesheet($exception), 200, array('Content-Type' => 'text/css'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<argument type="service" id="profiler" on-invalid="null" />
<argument type="service" id="twig" />
<argument>%kernel.debug%</argument>
<argument type="service" id="debug.file_link_formatter" />
</service>

<service id="web_profiler.csp.handler" class="Symfony\Bundle\WebProfilerBundle\Csp\ContentSecurityPolicyHandler">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

{% block body %}
<div class="header">
<h1>{{ file }} <small>line {{ line }}</small></h1>
<h1>{{ file }}{% if 0 < line %} <small>line {{ line }}</small>{% endif %}</h1>
<a class="doc" href="https://symfony.com/doc/{{ constant('Symfony\\Component\\HttpKernel\\Kernel::VERSION') }}/reference/configuration/framework.html#ide" rel="help">Open in your IDE?</a>
</div>
<div class="source">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class WebProfilerExtensionTest extends TestCase
public static function assertSaneContainer(Container $container, $message = '', $knownPrivates = array())
{
$errors = array();
$knownPrivates[] = 'debug.file_link_formatter.url_format';
foreach ($container->getServiceIds() as $id) {
if (in_array($id, $knownPrivates, true)) { // to be removed in 4.0
continue;
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.