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

Skip to content

Twig render helper doesn't work on IIS7 #6936

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

Closed
apt-thomas opened this issue Feb 1, 2013 · 1 comment
Closed

Twig render helper doesn't work on IIS7 #6936

apt-thomas opened this issue Feb 1, 2013 · 1 comment

Comments

@apt-thomas
Copy link

{{ render('foo') }} returns current action and render current template instend of action requested.

This happens because Symfony\Component\HttpFoundation\Request doesn't overwrite 'HTTP_X_ORIGINAL_URL', only 'REQUEST_URI'.

This can be fixed adding 'HTTP_X_ORIGINAL_URL' to the array used to overwrite the server variables:

Symfony\Component\HttpFoundation\Request line: 338:

$server = array_replace($defaults, $server, array(
    'REQUEST_METHOD' => strtoupper($method),
    'PATH_INFO'      => '',
    'REQUEST_URI'    => $uri,
    'QUERY_STRING'   => $queryString,
));

fix:

$server = array_replace($defaults, $server, array(
    'REQUEST_METHOD' => strtoupper($method),
    'PATH_INFO'      => '',
    'REQUEST_URI'    => $uri,
    'HTTP_X_ORIGINAL_URL' => $uri,
    'QUERY_STRING'   => $queryString,
 ));
@apt-thomas apt-thomas reopened this Feb 1, 2013
fabpot added a commit to fabpot/symfony that referenced this issue Feb 4, 2013
…stancies (closes symfony#6923, closes symfony#6936)

This fixes the creation of a sub-request when the master request Request URI
is determined with specific server information.
@fabpot
Copy link
Member

fabpot commented Feb 4, 2013

Can you confirm that #6966 fixes the issue?

fabpot added a commit that referenced this issue Feb 7, 2013
This PR was merged into the 2.0 branch.

Commits
-------

ddf4678 [HttpFoundation] fixed the creation of sub-requests under some circumstancies (closes #6923, closes #6936)

Discussion
----------

[HttpFoundation] fixed the creation of sub-requests under some circumstancies (closes #6923, closes #6936)

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #6923, #6936
| License       | MIT
| Doc PR        | n/a

This fixes the creation of a sub-request when the master request Request URI
is determined with specific server information.
@fabpot fabpot closed this as completed Feb 7, 2013
fabpot added a commit that referenced this issue Feb 7, 2013
* 2.0:
  [DependencyInjection] Allow frozen containers to be dumped to graphviz
  Add dot character `.` to legal mime subtype regular expression
  [HttpFoundation] fixed the creation of sub-requests under some circumstancies (closes #6923, closes #6936)
fabpot added a commit that referenced this issue Feb 11, 2013
* 2.1:
  added support for the X-Forwarded-For header (closes #6982, closes #7000)
  fixed the IP address in HttpCache when calling the backend
  [EventDispatcher] Added assertion.
  [EventDispathcer] Fix removeListener
  [DependencyInjection] Add clone for resources which were introduced in 2.1
  [DependencyInjection] Allow frozen containers to be dumped to graphviz
  Fix 'undefined index' error, when entering scope recursively
  [Security] fixed session creation on login (closes #7011)
  Add dot character `.` to legal mime subtype regular expression
  [HttpFoundation] fixed the creation of sub-requests under some circumstancies (closes #6923, closes #6936)
fabpot added a commit that referenced this issue Feb 11, 2013
* 2.2:
  Fixed XmlFileLoaderTest::testLoadThrowsExceptionWithInvalidFileEvenWithoutSchemaValidation
  moved file hash calculation to own method
  [Validator] Add check for existing metadata on property
  added support for the X-Forwarded-For header (closes #6982, closes #7000)
  fixed the IP address in HttpCache when calling the backend
  [EventDispatcher] Added assertion.
  [EventDispathcer] Fix removeListener
  [DependencyInjection] Add clone for resources which were introduced in 2.1
  [DependencyInjection] Allow frozen containers to be dumped to graphviz
  Fix 'undefined index' error, when entering scope recursively
  [Security] fixed session creation on login (closes #7011)
  replaced usage of the deprecated pattern routing key (replaced with path)
  Add dot character `.` to legal mime subtype regular expression
  [HttpFoundation] fixed the creation of sub-requests under some circumstancies (closes #6923, closes #6936)
fabpot added a commit that referenced this issue Apr 20, 2013
This PR was merged into the 2.1 branch.

Discussion
----------

[HttpFoundation] fixes creation of sub requests under IIS & Rewite Module

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

There are a few bugs to address.

1. `HTTP_X_ORIGINAL_URL` wasn't removed from the server parameters, so is picked back up [here](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/ServerBag.php#L33) upon recreation of a sub request.
2. When `X_ORIGINAL_URL` is passed in the headers by IIS, `IIS_WasUrlRewritten` and `UNENCODED_URL` can also be passed as server vars, so they must also be removed for sub request URI's to be resolved correctly.

Additionally, I have removed the OS check for windows, because it was only done for 2 out of 4 of the IIS specific checks, and it made the code untestable.

Also added tests for all scenarios as there were none.

Commits
-------

9fcd2f6 [HttpFoundation] fixed the creation of sub-requests under some circumstances for IIS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants