Skip to content
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

[HttpFoundation] Fix cookie to string conversion for raw cookies #20910

Closed
wants to merge 3 commits into from
Closed

[HttpFoundation] Fix cookie to string conversion for raw cookies #20910

wants to merge 3 commits into from

Conversation

ro0NL
Copy link
Contributor

@ro0NL ro0NL commented Dec 13, 2016

Q A
Branch? 3.1
Bug fix? yes
New feature? not really
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #20569 (comment)
License MIT
Doc PR symfony/symfony-docs#...

Separated from #20569

This mimics PHP's setrawcookie behavior.

if ($this->path) {
$str .= '; path='.$this->path;
}
$str .= '; path='.$this->getPath() ?: '/';
Copy link
Contributor Author

@ro0NL ro0NL Dec 13, 2016

Choose a reason for hiding this comment

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

See #20569 (comment) for my reasoning behind this. Im also fine with if ($this->getPath()) { ... } in case the user breaks the contract from a subclass.

Copy link
Member

Choose a reason for hiding this comment

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

I prefer to keep the condition to keep the payload small (I know that path= / is not that long, but as this is optional, let's do it that way).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree. However source of the problem is https://github.com/symfony/symfony/pull/20910/files#diff-a1e299c557d5ff5fde6fa480eab85d47R70

If it's truly optional (and it is :)) symfony should make no assumptions on empty values. Imo. passing $path=null, $path='', $path='/' should all behave as expected, respectively; <no-path>, path=;, path=/;

Perhaps something to look into later on. For now ill put back the condition 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@ro0NL
Copy link
Contributor Author

ro0NL commented Dec 13, 2016

Failing test (PHP7/redis) seems unrelated.

@fabpot
Copy link
Member

fabpot commented Dec 14, 2016

Thank you @ro0NL.

fabpot added a commit that referenced this pull request Dec 14, 2016
…ookies (ro0NL)

This PR was squashed before being merged into the 3.1 branch (closes #20910).

Discussion
----------

[HttpFoundation] Fix cookie to string conversion for raw cookies

| Q             | A
| ------------- | ---
| Branch?       | 3.1
| Bug fix?      | yes
| New feature?  | not really
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #20569 (comment)
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!--highly recommended for new features-->

Separated from #20569

This mimics PHP's `setrawcookie` behavior.

Commits
-------

5e899cd [HttpFoundation] Fix cookie to string conversion for raw cookies
@fabpot fabpot closed this Dec 14, 2016
@ro0NL ro0NL deleted the http-foundation/raw-cookie branch December 14, 2016 07:44
This was referenced Jan 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants