|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81433 DOMElement::setIdAttribute(attr, true) called twice removes ID
Submitted: 2021-09-13 05:51 UTC Modified: -
From: vv_volkov at mail dot ru Assigned:
Status: Closed Package: DOM XML related
PHP Version: 7.4.23 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
14 + 25 = ?
Subscribe to this entry?

 [2021-09-13 05:51 UTC] vv_volkov at mail dot ru
The method DOMElement::setIdAttribute(attr, true) works incorrectly. When called twice, it removes identity from the attribute. This pull request - - contains the bug fix

Test script:
$dom = new DOMDocument('1.0', 'utf-8');

$element = $dom->createElement('test', 'root');


$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


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-09-13 08:20 UTC]
The following pull request has been associated:

Patch Name: fix(php_set_attribute_id): fix incorrect ID removal, when is_id == 1
On GitHub:
 [2021-09-13 10:15 UTC]
Automatic comment on behalf of vicvolk (author) and cmb69 (committer)
Log: Fix #81433: DOMElement::setIdAttribute() called twice may remove ID
 [2021-09-13 10:15 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Oct 02 02:01:25 2023 UTC