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

Fixed unsetting from loosely equal keys OrderedHashMap #24566

Merged
merged 1 commit into from Oct 16, 2017
Merged

Fixed unsetting from loosely equal keys OrderedHashMap #24566

merged 1 commit into from Oct 16, 2017

Conversation

maryo
Copy link
Contributor

@maryo maryo commented Oct 15, 2017

Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #24558
License MIT

@nicolas-grekas nicolas-grekas added this to the 2.7 milestone Oct 16, 2017
@fabpot
Copy link
Member

fabpot commented Oct 16, 2017

Thank you @maryo.

@fabpot fabpot merged commit ba37cba into symfony:2.7 Oct 16, 2017
fabpot added a commit that referenced this pull request Oct 16, 2017
…ryo)

This PR was merged into the 2.7 branch.

Discussion
----------

Fixed unsetting from loosely equal keys OrderedHashMap

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #24558
| License       | MIT

Commits
-------

ba37cba Fixed unsetting from loosely equal keys OrderedHashMap
@@ -144,7 +144,7 @@ public function offsetSet($key, $value)
*/
public function offsetUnset($key)
{
if (false !== ($position = array_search($key, $this->orderedKeys))) {
if (false !== ($position = array_search((string) $key, $this->orderedKeys))) {
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it have been enough to pass true as the third argument here?

Copy link
Contributor Author

@maryo maryo Nov 13, 2017

Choose a reason for hiding this comment

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

@xabbuh https://3v4l.org/vBboa
When unsetting a numeric string offset like unset($map['1']), $key equals to integer 1. So it's needed to treat these numeric strings the same way as integers. Hence the cast. And since $this->orderedKeys are all strings (the new cast in offsetSet), passing true would result in the same.

This was referenced Oct 30, 2017
This was referenced Nov 10, 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.

None yet

5 participants