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

Skip to content

[WebProfiler] FileLinkFormatter no longer respecting xdebug.file_link_format when request exists #31833

Closed
@koddistortion

Description

@koddistortion

Symfony version(s) affected: 4.3.0

Description
Since upgrading from Symfony 4.2.9 to 4.3.0 the WebProfiler or more precisley the FileLinkFormatter no longer seems to make use of the xdebug.file_link_format option when generating URLs.

My current setup has the following xdebug.file_link_format option in my php.ini:

xdebug.file_link_format="phpstorm://open?url=file://%f&line=%l"

When browsing my application, I would expect the profiler to generate URLs to the sourc code in the following format:

phpstorm://open?url=file://C:\Users\xxx\git\my_dev\src\My\Bundle\MyBundle\Controller\DashboardController.php&line=20

But instead I always get the following:

http://my.dev.local/app_dev.php/_profiler/open?file=src\My\Bundle\MyBundle\Controller\DashboardController.php&line=20#line20

This is quite annoying as I would really like to use my IDE in order to browse the source code rather that an HTML version provided by the web profiler.

How to reproduce

  • Check that you have xdebug.file_link_format defined in php.ini with a valid value
  • Check that you do NOT have framework.ide option set (at least I don't have)
  • Upgrade to Symfony 4.3.0
  • Browse your application and check the profiler links to your source code

Possible Solution
It seems, that the commit 5fcd6b1 for src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php initally caused the problem.

In order to solve this locally, I manually updated the FileLinkFormatter::getFileLinkFormat() function:

before:

    private function getFileLinkFormat()
    {
        if ($this->requestStack && $this->baseDir && $this->urlFormat) {
            $request = $this->requestStack->getMasterRequest();

            if ($request instanceof Request && (!$this->urlFormat instanceof \Closure || $this->urlFormat = ($this->urlFormat)())) {
                $this->fileLinkFormat = [
                    $request->getSchemeAndHttpHost().$request->getBasePath().$this->urlFormat,
                    $this->baseDir.\DIRECTORY_SEPARATOR, '',
                ];
            }
        }

        return $this->fileLinkFormat;
    }

after:

    private function getFileLinkFormat()
    {
        if ($this->fileLinkFormat) {
            return $this->fileLinkFormat;
        }
        if ($this->requestStack && $this->baseDir && $this->urlFormat) {
            $request = $this->requestStack->getMasterRequest();

            if ($request instanceof Request && (!$this->urlFormat instanceof \Closure || $this->urlFormat = ($this->urlFormat)())) {
                $this->fileLinkFormat = [
                    $request->getSchemeAndHttpHost().$request->getBasePath().$this->urlFormat,
                    $this->baseDir.\DIRECTORY_SEPARATOR, '',
                ];
            }
        }

        return $this->fileLinkFormat;
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions