Skip to content
This repository has been archived by the owner on Jul 4, 2018. It is now read-only.

Move query string hack for request context to listener #662

Closed

Conversation

igorw
Copy link
Contributor

@igorw igorw commented Mar 27, 2013

Currently the UrlMatcher depends on the request context which leads to all
kinds of funky problems. Including failing tests in the current test suite.

The solution is to have the request context no longer directly depend on
the request, but instead populate the required information from a request
listener.

Better names for the listener are welcome.

PS: This solution feels kind of off to me. Shouldn't this case be handled by symfony/routing's RequestContext::fromRequest() directly? And if not, why?

Currently the UrlMatcher depends on the request context which leads to all
kinds of funky problems. Including failing tests in the current test suite.

The solution is to have the request context no longer directly depend on
the request, but instead populate the required information from a request
listener.
@igorw
Copy link
Contributor Author

igorw commented Mar 27, 2013

Refs #661.


$request = $event->getRequest();
if ($request->server->get('QUERY_STRING') !== '') {
$this->app['request_context']->setParameter('QUERY_STRING', $request->server->get('QUERY_STRING'));
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't you inject only the RequestContext ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't that force instantiation, when it might not be necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, The app is injected for laziness. I did not want to create a LazyRequestContext, although if deemed necessary I can adjust the patch to do so.

Copy link
Contributor

Choose a reason for hiding this comment

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

@davedevelopment It would indeed force the instantiation of the request context when instantiating the dispatcher... but this is already done by the RouterListener a few lines above:

$dispatcher->addSubscriber(new RouterListener($urlMatcher, $app['request_context'], $app['logger']));

Copy link
Contributor

Choose a reason for hiding this comment

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

@igorw no need to create a lazy one as it is already instantiated anyway

Copy link
Contributor

Choose a reason for hiding this comment

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

@stof fair point!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. I will adjust my patch to inject the context directly.

No need for laziness, since it is created early (with the dispatcher)
either way.
@davedevelopment
Copy link
Contributor

👍

As @igorw mentioned, I think this could possibly have been treat as a bug in Symfony and fixed in the other branches, but I'd rather see this PR merged and reversed later if that's the case.

@fabpot
Copy link
Member

fabpot commented Mar 29, 2013

I've implemented the BC layer in a slightly different way, which I think is better: see #663

fabpot added a commit that referenced this pull request Apr 1, 2013
This PR was merged into the master branch.

Discussion
----------

fixed request dependency on the URL matcher

Alternative fix for #662

Commits
-------

5dc7c27 fixed request dependency on the URL matcher
@fabpot fabpot closed this Apr 1, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants