Bug #81433 [PATCH]: DOMElement::setIdAttribute(attr, true) called twice removes ID

From: Date: Mon, 13 Sep 2021 08:20:59 +0000
Subject: Bug #81433 [PATCH]: DOMElement::setIdAttribute(attr, true) called twice removes ID
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236557@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81433&edit=1 ID: 81433 Patch added by: cmb@php.net Reported by: vv_volkov at mail dot ru Summary: DOMElement::setIdAttribute(attr, true) called twice removes ID Status: Open Type: Bug Package: DOM XML related PHP Version: 7.4.23 Block user comment: N Private report: N New Comment: The following pull request has been associated: Patch Name: fix(php_set_attribute_id): fix incorrect ID removal, when is_id == 1 On GitHub: https://github.com/php/php-src/pull/7482 Patch: https://github.com/php/php-src/pull/7482.patch Previous Comments: ------------------------------------------------------------------------ [2021-09-13 05:51:10] vv_volkov at mail dot ru Description: ------------ The method DOMElement::setIdAttribute(attr, true) works incorrectly. When called twice, it removes identity from the attribute. This pull request - https://github.com/php/php-src/pull/7482 - contains the bug fix Test script: --------------- $dom = new DOMDocument('1.0', 'utf-8'); $element = $dom->createElement('test', 'root'); $dom->appendChild($element); $element->setAttribute("id", 123); $element->setIdAttribute("id", true); $node = $element->getAttributeNode("id"); echo $node->isId(), "\n"; $element->setIdAttribute("id", true); echo $node->isId(), "\n"; Expected result: ---------------- The second call must not remove ID from the attribute Actual result: -------------- ID is removed from the attribute ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=81433&edit=1

« previous php.bugs (#236557) next »