-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* PHP-8.2: Fix GH-11630: proc_nice_basic.phpt only works at certain nice levels Fix GH-11629: bug77020.phpt tries to send mail Fix GH-11625: DOMElement::replaceWith() doesn't replace node with DOMDocumentFragment but just deletes node or causes wrapping <></> depending on libxml2 version
- Loading branch information
Showing
4 changed files
with
96 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
--TEST-- | ||
GH-11625 (DOMElement::replaceWith() doesn't replace node with DOMDocumentFragment but just deletes node or causes wrapping <></> depending on libxml2 version) | ||
--EXTENSIONS-- | ||
dom | ||
--FILE-- | ||
<?php | ||
|
||
function test($mutator) { | ||
$html = <<<XML | ||
<body> | ||
<div></div><div></div> | ||
</body> | ||
XML; | ||
|
||
$dom = new DOMDocument(); | ||
$dom->loadXML($html); | ||
|
||
$divs = iterator_to_array($dom->getElementsByTagName('div')->getIterator()); | ||
$i = 0; | ||
foreach ($divs as $div) { | ||
$mutator($dom, $div, $i); | ||
echo $dom->saveHTML(); | ||
$i++; | ||
} | ||
} | ||
|
||
echo "--- Single replacement ---\n"; | ||
|
||
test(function($dom, $div, $i) { | ||
$fragment = $dom->createDocumentFragment(); | ||
$fragment->appendXML("<p>Hi $i!</p>"); | ||
$div->replaceWith($fragment); | ||
}); | ||
|
||
echo "--- Multiple replacement ---\n"; | ||
|
||
test(function($dom, $div, $i) { | ||
$fragment = $dom->createDocumentFragment(); | ||
$fragment->appendXML("<p>Hi $i!</p>"); | ||
$div->replaceWith($fragment, $dom->createElement('x'), "hello"); | ||
}); | ||
|
||
echo "--- Empty fragment replacement ---\n"; | ||
|
||
test(function($dom, $div, $i) { | ||
$fragment = $dom->createDocumentFragment(); | ||
$div->replaceWith($fragment); | ||
}); | ||
|
||
?> | ||
--EXPECT-- | ||
--- Single replacement --- | ||
<body> | ||
<p>Hi 0!</p><div></div> | ||
</body> | ||
<body> | ||
<p>Hi 0!</p><p>Hi 1!</p> | ||
</body> | ||
--- Multiple replacement --- | ||
<body> | ||
<p>Hi 0!</p><x></x>hello<div></div> | ||
</body> | ||
<body> | ||
<p>Hi 0!</p><x></x>hello<p>Hi 1!</p><x></x>hello | ||
</body> | ||
--- Empty fragment replacement --- | ||
<body> | ||
<div></div> | ||
</body> | ||
<body> | ||
|
||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters