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

Skip to content

[WebProfilerBundle] use the router to resolve file links #26626

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

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 3.4
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #22290, #25886
License MIT
Doc PR -

<argument>?file=%%f&amp;line=%%l#line%%l</argument>
</argument>
</service>
</argument>
Copy link
Member Author

@nicolas-grekas nicolas-grekas Mar 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this generates the following code, which is exactly what we need here:

new \Symfony\Component\HttpKernel\Debug\FileLinkFormatter(NULL, ($this->services['request_stack'] ?? $this->services['request_stack'] = new \Symfony\Component\HttpFoundation\RequestStack()), $this->targetDirs[3], \implode(array(0 => ($this->services['router'] ?? $this->getRouterService())->generate('_profiler_open_file'), 1 => '?file=%f&line=%l#line%l')));

@@ -56,7 +56,20 @@
<argument>%debug.file_link_format%</argument>
<argument type="service" id="request_stack" on-invalid="ignore" />
<argument>%kernel.project_dir%</argument>
<argument>/_profiler/open?file=%%f&amp;line=%%l#line%%l</argument>
<argument type="service">
<service class="string">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice hack!

<argument>/_profiler/open?file=%%f&amp;line=%%l#line%%l</argument>
<argument type="service">
<service class="string">
<factory function="implode" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, and yet another nice hack!
Well done :)

@javiereguiluz
Copy link
Member

javiereguiluz commented Mar 22, 2018

@nicolas-grekas my head exploded when trying to understand this ... but I'm glad this is working 🎉

However, the main concern of Fabien in the other PR (see #24153 (comment)) was the configurability of this. So, can you please paste an example of the config needed if the user wants to customize the URL? We'd need it to update the docs. Thanks!

@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented Mar 22, 2018

@javiereguiluz there is no config needed, the URL will be generated based on the path of the _profiler_open_file route. If you want another route, do it yourself (but that's not what the original issue asked for.)

@nicolas-grekas nicolas-grekas merged commit 2cfc573 into symfony:3.4 Mar 22, 2018
nicolas-grekas added a commit that referenced this pull request Mar 22, 2018
…nicolas-grekas)

This PR was merged into the 3.4 branch.

Discussion
----------

[WebProfilerBundle] use the router to resolve file links

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #22290, #25886
| License       | MIT
| Doc PR        | -

Commits
-------

2cfc573 [WebProfilerBundle] use the router to resolve file links
@nicolas-grekas nicolas-grekas deleted the generate-profiler-open-link branch March 22, 2018 15:05
This was referenced Apr 3, 2018
@ahilles107
Copy link

ahilles107 commented Apr 3, 2018

It creates a BC break as router tries to generate route on container dumping.


  [PDOException (HY000)]
  SQLSTATE[HY000]: General error: 1 no such table: swp_route


Exception trace:
 PDO->prepare() at /Users/pawelmikolajczuk/Projects/web-publisher/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:77
 Doctrine\DBAL\Driver\PDOConnection->prepare() at /Users/pawelmikolajczuk/Projects/web-publisher/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:904
 Doctrine\DBAL\Connection->executeQuery() at /Users/pawelmikolajczuk/Projects/web-publisher/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:733
 Doctrine\ORM\Persisters\Entity\BasicEntityPersister->load() at /Users/pawelmikolajczuk/Projects/web-publisher/vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php:196
 Doctrine\ORM\EntityRepository->findOneBy() at /Users/pawelmikolajczuk/Projects/web-publisher/src/SWP/Bundle/ContentBundle/Provider/ORM/RouteProvider.php:183
 SWP\Bundle\ContentBundle\Provider\ORM\RouteProvider->getRouteByName() at /Users/pawelmikolajczuk/Projects/web-publisher/app/cache/test/ContainerMt0kps0/RouteProvider_370e34c.php:110
 RouteProvider_370e34c->getRouteByName() at /Users/pawelmikolajczuk/Projects/web-publisher/vendor/symfony-cmf/routing/src/ContentAwareGenerator.php:102
 Symfony\Cmf\Component\Routing\ContentAwareGenerator->getRouteByName() at /Users/pawelmikolajczuk/Projects/web-publisher/vendor/symfony-cmf/routing/src/ContentAwareGenerator.php:74
 Symfony\Cmf\Component\Routing\ContentAwareGenerator->generate() at /Users/pawelmikolajczuk/Projects/web-publisher/vendor/symfony-cmf/routing/src/DynamicRouter.php:179
 Symfony\Cmf\Component\Routing\DynamicRouter->generate() at /Users/pawelmikolajczuk/Projects/web-publisher/src/SWP/Bundle/CoreBundle/Routing/MetaRouter.php:65
 SWP\Bundle\CoreBundle\Routing\MetaRouter->generate() at /Users/pawelmikolajczuk/Projects/web-publisher/vendor/symfony-cmf/routing/src/ChainRouter.php:233
 Symfony\Cmf\Component\Routing\ChainRouter->generate() at /Users/pawelmikolajczuk/Projects/web-publisher/app/cache/test/ContainerMt0kps0/appTestDebugProjectContainer.php:3864
 ContainerMt0kps0\appTestDebugProjectContainer->getDebug_FileLinkFormatterService() at /Users/pawelmikolajczuk/Projects/web-publisher/app/cache/test/ContainerMt0kps0/appTestDebugProjectContainer.php:2986
 ContainerMt0kps0\appTestDebugProjectContainer->getTwigService() at /Users/pawelmikolajczuk/Projects/web-publisher/app/cache/tes_/ContainerMt0kps0/getTwig_CacheWarmerService.php:9
 ContainerMt0kps0\appTestDebugProjectContainer->{closure}() at /Users/pawelmikolajczuk/Projects/web-publisher/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ServiceLocator.php:64
 Symfony\Component\DependencyInjection\ServiceLocator->get() at /Users/pawelmikolajczuk/Projects/web-publisher/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheCacheWarmer.php:63
 Symfony\Bundle\TwigBundle\CacheWarmer\TemplateCacheCacheWarmer->warmUp() at /Users/pawelmikolajczuk/Projects/web-publisher/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php:52
 Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp() at /Users/pawelmikolajczuk/Projects/web-publisher/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:203
 Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->warmup() at /Users/pawelmikolajczuk/Projects/web-publisher/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:133
 Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->execute() at /Users/pawelmikolajczuk/Projects/web-publisher/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:252
 Symfony\Component\Console\Command\Command->run() at /Users/pawelmikolajczuk/Projects/web-publisher/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:964
 Symfony\Component\Console\Application->doRunCommand() at /Users/pawelmikolajczuk/Projects/web-publisher/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:86
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /Users/pawelmikolajczuk/Projects/web-publisher/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:248
 Symfony\Component\Console\Application->doRun() at /Users/pawelmikolajczuk/Projects/web-publisher/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:74
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /Users/pawelmikolajczuk/Projects/web-publisher/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:148
 Symfony\Component\Console\Application->run() at /Users/pawelmikolajczuk/Projects/web-publisher/app/console:30

cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [-t|--tenant TENANT] [--] <command>

We have routes in database and at the end database is checked on container generation (cache:clear command)

@thijskaspers
Copy link

thijskaspers commented Apr 3, 2018

Same here with bin/console debug:router --env=ci:

In appCiDebugProjectContainerUrlGenerator.php line 81:
                                                                                                    
  Unable to generate a URL for the named route "_profiler_open_file" as such route does not exist.

The 'ci' environment loads the Symfony\Bundle\WebProfilerBundle\WebProfilerBundle() in AppKernel.php so what I am doing wrong here?

@fabpot
Copy link
Member

fabpot commented Apr 3, 2018

Shall we revert?

@nicolas-grekas
Copy link
Member Author

It depends on the time we want, fix in progress, could be ready tomorrow.

@nicolas-grekas
Copy link
Member Author

Fix in #26758

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants