mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix #81433: DOMElement::setIdAttribute() called twice may remove ID
This commit is contained in:
commit
6fbdf69628
3 changed files with 32 additions and 5 deletions
3
NEWS
3
NEWS
|
@ -2,6 +2,9 @@ PHP NEWS
|
|||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
?? ??? 2021, PHP 8.0.12
|
||||
|
||||
- DOM:
|
||||
. Fixed bug #81433 (DOMElement::setIdAttribute() called twice may remove ID).
|
||||
(Viktor Volkov)
|
||||
|
||||
23 Sep 2021, PHP 8.0.11
|
||||
|
||||
|
|
|
@ -1024,11 +1024,9 @@ static void php_set_attribute_id(xmlAttrPtr attrp, zend_bool is_id) /* {{{ */
|
|||
xmlAddID(NULL, attrp->doc, id_val, attrp);
|
||||
xmlFree(id_val);
|
||||
}
|
||||
} else {
|
||||
if (attrp->atype == XML_ATTRIBUTE_ID) {
|
||||
xmlRemoveID(attrp->doc, attrp);
|
||||
attrp->atype = 0;
|
||||
}
|
||||
} else if (is_id == 0 && attrp->atype == XML_ATTRIBUTE_ID) {
|
||||
xmlRemoveID(attrp->doc, attrp);
|
||||
attrp->atype = 0;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
|
26
ext/dom/tests/bug81433.phpt
Normal file
26
ext/dom/tests/bug81433.phpt
Normal file
|
@ -0,0 +1,26 @@
|
|||
--TEST--
|
||||
Bug #81433 (DOMElement::setIdAttribute(attr, true) called twice removes ID)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once('skipif.inc');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$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");
|
||||
var_dump($node->isId());
|
||||
|
||||
$element->setIdAttribute("id", true);
|
||||
var_dump($node->isId());
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(true)
|
Loading…
Add table
Add a link
Reference in a new issue