Skip to content

OrderedHashMap compares keys loosely #24558

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
maryo opened this issue Oct 14, 2017 · 0 comments
Closed

OrderedHashMap compares keys loosely #24558

maryo opened this issue Oct 14, 2017 · 0 comments

Comments

@maryo
Copy link
Contributor

maryo commented Oct 14, 2017

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.3.10
$map = new OrderedHashMap();
$map['1 as a string'] = '1 as a string';
$map[1] = '1 as an integer';

unset($map[1]);

var_dump($map);

https://3v4l.org/ZWo3B

As you can see, after the unset of 1, it was correctly unset from the internal elements array. But incorrect key was removed from orderedKeys property. The key should be probably stored as a string and converted back when obtaining it so it behaves the same way as PHP array.
OrderedHashMapIterator needs to be adjusted as well.

fabpot added a commit that referenced this issue 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
@fabpot fabpot closed this as completed Oct 16, 2017
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

4 participants