[bug][Profiler] Route matching logs do not respect host in routing files #6744

Closed
luiges90 opened this Issue Jan 15, 2013 · 5 comments

Projects

None yet

4 participants

@luiges90

In the routing page under profiler, the route matching logs does not take host in the routing files into account, and giving inconsistent results with the actual routed page. This could be a hurdle in debugging.

i.e. with the following configuration, going into example.com will show mobile_homepage being matched, despite a 404 error is thrown.

/* app/config/routing.yml */
mobile:
    resource: "@AcmeMobileBundle/Resources/config/routing.yml"
    host: m.example.com
    prefix:   /

desktop:
    resource: "@AcmeDesktopBundle/Resources/config/routing.yml"
    prefix:   /
/* src/Acme/MobileBundle/Resources/config/routing.yml */
mobile_homepage:
    pattern:  /
    defaults: { _controller: AcmeMobileBundle:some:controller }
/* src/Acme/DesktopBundle/Resources/config/routing.yml */
desktop_homepage:
    pattern:  /page/
    defaults: { _controller: AcmeDesktopBundle:some:controller }

Always reproducible.

I am on Sf 2.2.0-DEV (6755546) with PHP 5.4.4 on Mac OS X 10.7.3

@dlsniper
Contributor

Hi there,

I've tried to replicate this by having the following configuration:

_welcome:
    pattern:  /page/
    hostname: fat-sf2
    defaults: { _controller: AcmeDemoBundle:Welcome:index }

_welcome2:
    pattern:  /
    hostname: m.fat-sf2
    defaults: { _controller: AcmeDemo2Bundle:Welcome:index }

I've tested against http://fat-sf2/, which should trigger the error if I understood your example right, but I've yet to replicate the problem. I do however run against the master setup and there the hostname_pattern isn't a valid entry while hostname is.

Best regards.

@luiges90

Your example sounds right to me, but would it be because of imported routes (unlikely)? Possibly my version isn't newest.

And apparently I cannot test with newest version at the moment because of #6730

@luiges90

Just checked out the newest version 6755546 and the bug still persists.
btw, it seems host is the correct key as in the newest version, as when I use hostname Symfony complains about wrong option.

Updated my code to reflect the newest changes on my side.

@fabpot fabpot added a commit that referenced this issue Feb 7, 2013
@fabpot fabpot merged branch canni/fix_traceable_matcher (PR #7009)
This PR was merged into the 2.2 branch.

Commits
-------

30b0c37 [Router] Fix TraceableUrlMatcher

Discussion
----------

[BugFix][Router] Fix TraceableUrlMatcher

TraceableUrlMatcher does not take care with new host route features

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #6744
| License       | MIT
| Doc PR        | n/a
0f8d417
@luiges90

Checked out the newest version. Now while it shows m.example.com does not match example.com, the matching logs stop there.

Isn't really right - especially if there is another rule that actually match and shows that page after it, the logs is unable to show the matched route.

i.e. in above example, if I have an additional rule:

/* src/Acme/DesktopBundle/Resources/config/routing.yml */
desktop_homepage:
    pattern:  /page/
    defaults: { _controller: AcmeDesktopBundle:some:controller }

desktop_main:
    pattern:  /
    defaults: { _controller: AcmeDesktopBundle:some:mainController }

It is unable to show the it matches desktop_main

@alex88
Contributor
alex88 commented Aug 5, 2013

I'm having another issue, maybe related to this, I've two routes, with both pattern (/pattern/{parameter}) just included in app/config/routing.yml with different hosts, in profiler the matching process goes through the routes but since I'm requesting sub2.site.com and first matching route with /pattern/{parameter} is the sub1.site.com host it stops there saying "Host "sub1" does not match the requirement ("{subdomain}.{domain}")"

@fabpot fabpot added a commit that referenced this issue Dec 15, 2013
@fabpot fabpot bug #9760 [Routing] Fix router matching pattern against multiple host…
…s (karolsojko)

This PR was merged into the 2.3 branch.

Discussion
----------

[Routing] Fix router matching pattern against multiple hosts

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

When you had a pattern that matched on multiple host then only the first one was displayed as "almost matching". Fixed router matching against the same pattern on multiple hosts so now it shows every "almost match" on different hosts.

Commits
-------

f727b22 [Routing] Fix router matching pattern against multiple hosts
f056ac1
@fabpot fabpot closed this Dec 15, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment