|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-09-22 22:26 UTC] beberlei@php.net
-Status: Open
+Status: Not a bug
-Assigned To:
+Assigned To: beberlei
[2019-09-22 22:26 UTC] beberlei@php.net
[2019-09-23 06:15 UTC] goetas at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 09:00:01 2025 UTC |
Description: ------------ Strange object allocation issue, maybe related to PHP/LIBXML memory handling. I've supposed that PHP releases the object associated to $root when I unset it (even if this object can be reached through $dom->documentElement). Later, when I create the $ele element, it takes the same memory position of $root. LIBXML version 2.7.8 Test script: --------------- $dom = new \DOMDocument('1.0', 'UTF-8'); $root = $dom->createElement('root'); $dom->appendChild($root); $h1 = spl_object_hash($root); $h2 = spl_object_hash($dom->documentElement); var_dump($root === $dom->documentElement); // true, OK var_dump($h1 === $h2); // true, OK unset($root); $ele = $dom->createElement('ele'); $h3 = spl_object_hash($ele); $h4 = spl_object_hash($dom->documentElement); var_dump($h1 === $h3); // expected to be false, but actually true var_dump($h1 === $h4); // expected to be true, but actually false Expected result: ---------------- bool(true) bool(true) bool(false) bool(true) Actual result: -------------- bool(true) bool(true) bool(true) bool(false)