[php-src] PR #11369: Fix bug #77686: Removed elements are still returned by getElementById
| From: | nielsdos | Date: | Sun, 04 Jun 2023 13:29:51 +0000 |
| Subject: | [php-src] PR #11369: Fix bug #77686: Removed elements are still returned by getElementById | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-22654@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/11369
Author: nielsdos
From the moment an ID is created, libxml2's behaviour is to cache that element, even if that
element is not yet attached to the document. Similarly, only upon destruction of the element the ID
is actually removed by libxml2. Since libxml2 has such behaviour deeply ingrained in the library,
and uses the cache for various purposes, it seems like a bad idea and lost cause to fight it.
Instead, we'll simply walk the tree upwards to check if the node is attached to the document.
There was a previous PR attempt for this here: https://github.com/php/php-src/pull/6936. The
approach in this PR is different and does not increase the cost of element removal.