php.net |  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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: vv_volkov at mail dot ru
New email:
PHP Version: OS:

 

 [2021-09-13 05:51 UTC] 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

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-09-13 08:20 UTC] cmb@php.net
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
 [2021-09-13 10:15 UTC] git@php.net
Automatic comment on behalf of vicvolk (author) and cmb69 (committer)
Revision: https://github.com/php/php-src/commit/424c2654780b7d216abfc5eef37b8d73f1fe5df4
Log: Fix #81433: DOMElement::setIdAttribute() called twice may remove ID
 [2021-09-13 10:15 UTC] git@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC