mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Handle strict error properly in adoptNode failure, and add a test
This commit is contained in:
parent
6fc8ab2eb8
commit
6f6fedcb46
2 changed files with 17 additions and 4 deletions
|
@ -1064,7 +1064,7 @@ PHP_METHOD(DOMDocument, adoptNode)
|
|||
|| nodep->type == XML_ENTITY_NODE
|
||||
|| nodep->type == XML_NOTATION_NODE)) {
|
||||
php_dom_throw_error(NOT_SUPPORTED_ERR, dom_get_strict_error(dom_object_nodep->document));
|
||||
RETURN_THROWS();
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
xmlDocPtr new_document;
|
||||
|
|
|
@ -43,7 +43,7 @@ $adopted = $doc1->adoptNode($doc1->firstChild->firstChild);
|
|||
var_dump($adopted->textContent);
|
||||
var_dump($doc1->saveXML());
|
||||
|
||||
echo "-- Adopt a document --\n";
|
||||
echo "-- Adopt a document (strict error on) --\n";
|
||||
|
||||
try {
|
||||
$doc1->adoptNode($doc1);
|
||||
|
@ -51,6 +51,16 @@ try {
|
|||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
echo "-- Adopt a document (strict error off) --\n";
|
||||
|
||||
$doc1->strictErrorChecking = false;
|
||||
try {
|
||||
$doc1->adoptNode($doc1);
|
||||
} catch (\DOMException $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
$doc1->strictErrorChecking = true;
|
||||
|
||||
echo "-- Adopt an attribute --\n";
|
||||
|
||||
$doc3 = new DOMDocument();
|
||||
|
@ -102,7 +112,7 @@ unset($doc1);
|
|||
var_dump($child->nodeName);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
--EXPECTF--
|
||||
-- Owner document check before adopting --
|
||||
bool(true)
|
||||
bool(false)
|
||||
|
@ -127,8 +137,11 @@ string(5) "world"
|
|||
string(27) "<?xml version="1.0"?>
|
||||
<p/>
|
||||
"
|
||||
-- Adopt a document --
|
||||
-- Adopt a document (strict error on) --
|
||||
Not Supported Error
|
||||
-- Adopt a document (strict error off) --
|
||||
|
||||
Warning: DOMDocument::adoptNode(): Not Supported Error in %s on line %d
|
||||
-- Adopt an attribute --
|
||||
bool(true)
|
||||
bool(true)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue