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 spl_object_hash collisions using internal attribute. #24

Merged
merged 3 commits into from
May 1, 2015

Conversation

goetas
Copy link
Owner

@goetas goetas commented Apr 25, 2015

Fixes #23

Test suite is still missing

goetas referenced this pull request Apr 25, 2015
In certain edge case we can have spl_object_hash collisions, so lets use also some node data
{
return "__a9" . strtr(md5($node->ownerDocument->saveXML($node)).spl_object_hash($node), "-","_");
return "__a9" . strtr($node->getAttributeNS(Twital::NS, '__internal-id__').spl_object_hash($node), "-","_");
Copy link
Contributor

Choose a reason for hiding this comment

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

Wasn't the whole point of this to replace spl_object_hash with some unique key? Or maybe I just don't understand how it works now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I get it now. First part of hash is unique for current document and second part ensures that it won't colide with normal variables.

Copy link
Owner Author

Choose a reason for hiding this comment

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

It is also possible to create plugins that are able to "clone" dom nodes. Cloning a node, the __internal-id__ will remain untouched, so using both spl_object_hash and __internal-id__ the node identifier "should" be more reliable.

goetas added a commit that referenced this pull request May 1, 2015
Fixed spl_object_hash collisions using internal attribute.
@goetas goetas merged commit 372d235 into master May 1, 2015
@goetas goetas deleted the attr-collisions branch June 13, 2015 15:50
@goetas goetas restored the attr-collisions branch August 8, 2015 11:08
@goetas goetas deleted the attr-collisions branch August 23, 2015 10:31
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.

Attributes are duplicated multiple nodes
2 participants