8000 [HttpFoundation] fixed Request::create() method by fabpot · Pull Request #6995 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpFoundation] fixed Request::create() method #6995

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
merged 1 commit into from
Feb 7, 2013

Conversation

fabpot
Copy link
Member
@fabpot fabpot commented Feb 7, 2013
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR n/a

When creating a Request with Request::create(), some information can
come from the URI and the server variable. Until now, it was not clear
which information had precedence over the other and as a matter of fact,
this method was not consistent.

Now, information contained in the URI always take precedence over
information coming from the server array. That makes sense as the server
array is often copied from another existing Request object.

@vicb
Copy link
Contributor
vicb commented Feb 7, 2013

You should add a note in the changelog

When creating a Request with Request::create(), some information can
come from the URI and the server variable. Until now, it was not clear
which information had precedence over the other and as a matter of fact,
this method was not consistent.

Now, information contained in the URI always take precedence over
information coming from the server array. That makes sense as the server
array is often copied from another existing Request object.
fabpot added a commit that referenced this pull request Feb 7, 2013
This PR was merged into the 2.2 branch.

Commits
-------

bc4a0e7 [HttpFoundation] fixed Request::create() method

Discussion
----------

[HttpFoundation] fixed Request::create() method

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

When creating a Request with Request::create(), some information can
come from the URI and the server variable. Until now, it was not clear
which information had precedence over the other and as a matter of fact,
this method was not consistent.

Now, information contained in the URI always take precedence over
information coming from the server array. That makes sense as the server
array is often copied from another existing Request object.

---------------------------------------------------------------------------

by vicb at 2013-02-07T14:42:15Z

You should add a note in the changelog
@fabpot fabpot merged commit bc4a0e7 into symfony:2.2 Feb 7, 2013
@@ -267,7 +270,7 @@ public static function createFromGlobals()
*/
public static function create($uri, $method = 'GET', $parameters = array(), $cookies = array(), $files = array(), $server = array(), $content = null)
{
$defaults = array(
$server = array_replace(array(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just $server += array(...);?

Copy link
Contributor

Choose a reason for hiding this comment

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

@rybakit do you have any idea on the perf impact ? (out of my own curiosity)

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Quite micro difference anyway (notice it's visible when looping more than 10000 times)...

Copy link
Contributor

Choose a reason for hiding this comment

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

@rybakit, do you have XDebug enabled ? (If yes could you please re-test by disabling it).

Twice as fast is a notable difference IMO in favor of union.

Copy link
Contributor

Choose a reason for hiding this comment

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

@stloyd, true, but + array() is also more readable, at least for me.

@vicb, I had ZendDebugger enabled (rev 3). Check the latest gist rev 4 (without ZendDebugger).

Copy link
Contributor

Choose a reason for hiding this comment

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

@rybakit could you please create a new issue to discuss this as the PR has been closed - you suggestion is applicable at several places in the code. Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -4,6 +4,7 @@ CHANGELOG
2.2.0
-----

* fixed the Request::create() precedence (URI information always take precedence now)
Copy link
Contributor

Choose a reason for hiding this comment

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

As a widely used and @api tagged class, this probably deserves a "[BC BREAK]"

@sstok
Copy link
Contributor
sstok commented Feb 9, 2013

This seems to change breaks the Webkit Client.

When using HTTP auth and submitting a form using submit() the authorization is missing.

@fabpot
Copy link
Member Author
fabpot commented Feb 9, 2013

@sstok Can you give us a small script that reproduces the problem?

@sstok
Copy link
Contributor
sstok commented Feb 9, 2013

Will do.

@sstok
Copy link
Contributor
sstok commented Feb 9, 2013

https://github.com/sstok/symfony-standard/tree/webkit-client-http-auth

Its strange because the $crawler->filter() does not give any errors but isSuccessful() returns false.
When reverting this PR the problem still remains.

I will try the old composer.lock and see if the problem is still present.

Edit: Using an older version: 6c00ffe does not have this problem.

@sstok
Copy link
Contributor
sstok commented Feb 12, 2013

@fabpot any change you can take a look at this?

OK it seems its working now. Nope, I was to optimistic.

@vicb
Copy link
Contributor
vicb commented Feb 12, 2013

@sstok, the best would be to submit a "small" PR that reproduces the problem (ie a failing unit test that could be later integrated in Sf together with the fix)

@sstok
Copy link
Contributor
sstok commented Feb 13, 2013

https://github.com/sstok/symfony-standard/tree/webkit-client-http-auth This is what I was able to make on short notice. I will try to make a UnitTest pull request for the Framework repo.

OK that went a lot faster then simple testing code 😄

fabpot added a commit that referenced this pull request Feb 17, 2013
This PR was merged into the 2.2 branch.

Commits
-------

b240d1f [BrowserKit] added a test to make sure HTTP authentication is preserved when submitting a form

Discussion
----------

[WIP]BrowserKit] added a test to make sure HTTP authentication is preserved

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

Since #6995 BrowseKit no longer seems to preserve the HTTP authentication when submitting a form. This PR adds a test to demonstrate the failure.

---------------------------------------------------------------------------

by vicb at 2013-02-13T12:49:16Z

Thanks. Could you add a "[WIP]" prefix to the PR tittle and set "bug fix" to "no" for now ?

---------------------------------------------------------------------------

by sstok at 2013-02-13T13:59:42Z

done :+1:

---------------------------------------------------------------------------

by fabpot at 2013-02-17T12:49:35Z

This cannot be related to #6995 as your test does not involve any HttpFoundation classes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0