Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[WebProfilerBundle] Use absolute URL for profiler links#31349

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nicolas-grekas merged 1 commit intosymfony:3.4frommartijnhartlief:absolute-url
May 22, 2019

Conversation

@martijnhartlief
Copy link

QA
Branch?3.4
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?n/a
Fixed ticketsn/a
LicenseMIT
Doc PRn/a

Generate absolute URL's so you can have a different (sub)domain for the profiler and the controller that uses it.

Also uses the link which the controller generated instead of always generating a new link in Twig. The changes shouldn't inpact normal behavior.

ro0NL and mathroc reacted with thumbs up emoji
@stof
Copy link
Member

stof commentedMay 7, 2019

Can you give more details about how this solves your need to have different subdomains ? I don't think this is true here (most URLs generated in the controller are for redirections from a profiler controller to another one, and so they are already in the right subdomain anyway AFAICT)

@martijnhartlief
Copy link
Author

martijnhartlief commentedMay 7, 2019
edited
Loading

Well perhaps my fixes are totally wrong. What I noticed is that the profiler doesn't follow it's own host configuration. It generates links relative to itself, which makes sense, but when you "include" the profiler in that page it uses a different host, it will link to the parent host, and not the profiler's host. If your host is example.domain.com and the profiler's host is domain.com it generates the link /_profiler/token. But when you actually click it the page uses example.domain.com/_profiler/token. Which result's in a 404 if you don't have a route listening to that path.

Bear in mind I only tried to fix the probably unintended result of the profiler controller assuming it's running under the same host.

So to "force" the profiler to generate the correct link for the profiler, no matter where you requested from I added "Route::ABSOLUTE_URL" in the controller that generates it.

Then i found out that value is never read in the template because it will always generate the path in the template. There is probably a reason for this, but it resulted that the template generates the route again. Which also assumes it's already under the correct host. The controller passes the generated url, but is never used.

Maybe just changing to absolute_url() in twig is the correct way, and the actual controller doesn't need any modifications.

I know this is probably an edge case, but i would love to have all profiler links go to the same host instead of "wild-carding" it to all hosts, which is currently not possible.

@stof
Copy link
Member

stof commentedMay 9, 2019

hmm, as the toolbar is loaded asynchronously in an AJAX request, the host requirements indeed don't allow solving things properly for links generated in the toolbar items (the router will consider that the toolbar is already on a domain matching the requirement and so does not need to force an absolute URL, but the toolbar then gets injected into the page and relative links are resolved there).

The solution to your problem is to use url() instead ofpath() in the item template, and keeping only the change on line 167 of ProfilerController in your patch (the redirections don't need this change to work fine).

@martijnhartlief
Copy link
Author

I made the suggested changes

@fabpot
Copy link
Member

@martijnhartlief Can you squash the commits before I merge? Thank you.

…roller's domain which initialises the profiler.
@nicolas-grekas
Copy link
Member

Thank you@martijnhartlief.

@nicolas-grekasnicolas-grekas merged commit13ee1fa intosymfony:3.4May 22, 2019
nicolas-grekas added a commit that referenced this pull requestMay 22, 2019
…lumbrados)This PR was merged into the 3.4 branch.Discussion----------[WebProfilerBundle] Use absolute URL for profiler links| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | n/a| Fixed tickets | n/a| License       | MIT| Doc PR        | n/aGenerate absolute URL's so you can have a different (sub)domain for the profiler and the controller that uses it.Also uses the link which the controller generated instead of always generating a new link in Twig. The changes shouldn't inpact normal behavior.Commits-------13ee1fa Use absolute URL for when the profiler's domain differs from the controller's domain which initialises the profiler.
@fabpotfabpot mentioned this pull requestMay 28, 2019
@martijnhartliefmartijnhartlief deleted the absolute-url branchMay 28, 2019 11:08
This was referencedMay 28, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@stofstofstof requested changes

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

6 participants

@martijnhartlief@stof@fabpot@nicolas-grekas@carsonbot@Alumbrados

[8]ページ先頭

©2009-2025 Movatter.jp