Skip to content

[Bug]: libxml version 2.15.1 shipped with current php versions broken? #1617

@hirasso

Description

@hirasso

Platform

macOS

Operating system version

macOS 15.3.2 (24D81)

System architecture

ARM64 (M1, M2, etc)

Herd Version

1.24.2 (Build 59)

PHP Version

PHP 8.2, 8.3, 8.4

Bug description

Something seems very broken with libxml and DOMDocument parsing (??) since I updated the current PHP versions shipped with Laravel Herd.

Steps to reproduce

See the tests failing

Relevant log output

❯ composer test
PHPUnit 12.5.4 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.29
Configuration: /html5-dom-document-php/phpunit.xml

FFFFFFFEEEF.EFE.FFFEFF.................FFFFE.EFF..F               51 / 51 (100%)

Time: 00:00.020, Memory: 16.00 MB

There were 8 errors:

1) Test::testQuerySelector
Error: Call to a member function appendChild() on null

/html5-dom-document-php/src/HTML5DOMDocument.php:342
/html5-dom-document-php/src/HTML5DOMElement.php:57
/html5-dom-document-php/tests/Test.php:353

2) Test::testElementQuerySelector
Error: Call to a member function appendChild() on null

/html5-dom-document-php/src/HTML5DOMDocument.php:342
/html5-dom-document-php/src/HTML5DOMElement.php:57
/html5-dom-document-php/tests/Test.php:411

3) Test::testElementQuerySelectorCaseSensitivity
Error: Call to a member function appendChild() on null

/html5-dom-document-php/src/HTML5DOMDocument.php:342
/html5-dom-document-php/src/HTML5DOMElement.php:57
/html5-dom-document-php/tests/Test.php:473

4) Test::testComplexQuerySelectors3
Error: Call to a member function appendChild() on null

/html5-dom-document-php/src/HTML5DOMDocument.php:342
/html5-dom-document-php/src/HTML5DOMElement.php:57
/html5-dom-document-php/tests/Test.php:550

5) Test::testOuterHTML
Error: Call to a member function appendChild() on null

/html5-dom-document-php/src/HTML5DOMDocument.php:342
/html5-dom-document-php/src/HTML5DOMElement.php:75
/html5-dom-document-php/tests/Test.php:595

6) Test::testSaveHTMLForNodes
Error: Call to a member function appendChild() on null

/html5-dom-document-php/src/HTML5DOMDocument.php:342
/html5-dom-document-php/tests/Test.php:834

7) Test::testDuplicateElementIDsQueries
Error: Call to a member function appendChild() on null

/html5-dom-document-php/src/HTML5DOMDocument.php:342
/html5-dom-document-php/src/HTML5DOMElement.php:57
/html5-dom-document-php/tests/Test.php:1374

8) Test::testSpecialCharsInScriptTags
Error: Call to a member function appendChild() on null

/html5-dom-document-php/src/HTML5DOMDocument.php:342
/html5-dom-document-php/src/HTML5DOMElement.php:57
/html5-dom-document-php/tests/Test.php:1410

--

There were 21 failures:

1) Test::testSaveHTML
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<!DOCTYPE html><html><body><div>hello</...'
+'<!DOCTYPE html><!--?xml encoding="utf-8" ?--><html><body><div>hello</...'

/html5-dom-document-php/tests/Test.php:28
/html5-dom-document-php/tests/Test.php:34

2) Test::testOmitedElements
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<!DOCTYPE html><html><body><div>hello</...'
+'<!DOCTYPE html><!--?xml encoding="utf-8" ?--><html><body><div>hello</...'

/html5-dom-document-php/tests/Test.php:56
/html5-dom-document-php/tests/Test.php:62

3) Test::testUTF
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<!DOCTYPE html><html><body><div>hello</...'
+'<!DOCTYPE html><!--?xml encoding="utf-8" ?--><html><body><div>hello</...'

/html5-dom-document-php/tests/Test.php:86

4) Test::testNbspAndWhiteSpace
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<!DOCTYPE html><html><body><div> &nbsp;...'
+'<!DOCTYPE html><!--?xml encoding="utf-8" ?--><html><body><div> &nbsp;...'

/html5-dom-document-php/tests/Test.php:106

5) Test::testHtmlEntities
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<!DOCTYPE html><html><body><div data-va...'
+'<!DOCTYPE html><!--?xml encoding="utf-8" ?--><html><body><div data-va...'

/html5-dom-document-php/tests/Test.php:119

6) Test::testInsertHTML
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<!DOCTYPE html><html><head><meta custom="value"></head><body>text1<div>text2</div><div>text3</div></body></html>'
+'<!DOCTYPE html><!--?xml encoding="utf-8" ?--><html><head></head><body>text1</body></html>'

/html5-dom-document-php/tests/Test.php:145

7) Test::testEmpty
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<!DOCTYPE html><html><head></head><body></body></html>'
+'<!DOCTYPE html><!--?xml encoding="utf-8" ?--><html><head></head><body></body></html>'

/html5-dom-document-php/tests/Test.php:318
/html5-dom-document-php/tests/Test.php:322

8) Test::testComplexQuerySelectors
Failed asserting that false is true.

/html5-dom-document-php/tests/Test.php:509

9) Test::testInnerHTML
Failed asserting that false is true.

/html5-dom-document-php/tests/Test.php:569

10) Test::testFiles
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<!DOCTYPE html><html><body><div>text2</...'
+'<!DOCTYPE html><!--?xml encoding="utf-8" ?--><html><body><div>text2</...'

/html5-dom-document-php/tests/Test.php:653

11) Test::testDuplicateIDs
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<!DOCTYPE html><html><head><script id="script1">var script1=1;</script><script id="script1">var script1=2;</script></head><body></body></html>'
+'<!DOCTYPE html><!--?xml encoding="utf-8" ?--><html><head><body></body></head></html>'

/html5-dom-document-php/tests/Test.php:672

12) Test::testDuplicateTags
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<!DOCTYPE html><html><head><title>Title2</title></head></html>'
+'<!DOCTYPE html><!--?xml encoding="utf-8" ?--><html><head><title>Title1</title></head></html>'

/html5-dom-document-php/tests/Test.php:774

13) Test::testMultipleHeadAndBodyTags
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<!DOCTYPE html><html><head><meta charse...'
+'<!DOCTYPE html><!--?xml encoding="utf-8" ?--><html><head><meta charse...'

/html5-dom-document-php/tests/Test.php:904

14) Test::testInsertHTMLCopyAttributes
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<!DOCTYPE html><html data-html-custom-1="A" data-html-custom-2="B"><head data-head-custom-1="A" data-head-custom-2="B"></head><body data-body-custom-1="A" data-body-custom-2="B"></body></html>'
+'<!DOCTYPE html><!--?xml encoding="utf-8" ?--><html data-html-custom-1="A" data-html-custom-2="B"><head data-head-custom-1="A" data-head-custom-2="B"><body data-body-custom-1="A" data-body-custom-2="B"></body></head><body data-body-custom-1="1"></body></html>'

/html5-dom-document-php/tests/Test.php:928

15) Test::testWrongCharsetMetaTag
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<!DOCTYPE html><html><head><meta http-e...'
+'<!DOCTYPE html><!--?xml encoding="utf-8" ?--><html><head><meta http-e...'

/html5-dom-document-php/tests/Test.php:1262

16) Test::testLIBXML_HTML_NODEFDTD
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<!--?xml encoding="utf-8" ?--><html><body><div>hello</di...'
+'<html><body><div>hello</di...'

/html5-dom-document-php/tests/Test.php:1274

17) Test::testLIBXML_HTML_NOIMPLIED
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<!DOCTYPE html><!--?xml encoding="utf-8" ?--><div>hello</div>'
+'<!DOCTYPE html><div>hello</div>'

/html5-dom-document-php/tests/Test.php:1289

18) Test::testCompatibilityWithDOMDocument
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '<!DOCTYPE html>\n
-<!--?xml encoding="utf-8" ?--><div>hello</div>'
+<div>hello</div>'

/html5-dom-document-php/tests/Test.php:1315
/html5-dom-document-php/tests/Test.php:1351

19) Test::testFragments
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<div>text</div>'
+'<!--?xml encoding="utf-8" ?--><div>text</div>'

/html5-dom-document-php/tests/Test.php:1429

20) Test::testScriptsCDATA
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<!DOCTYPE html><html><body><script type...'
+'<!DOCTYPE html><!--?xml encoding="utf-8" ?--><html><body><script type...'

/html5-dom-document-php/tests/Test.php:1443

21) Test::testAllowDuplicateIDsWhenModifyingElements
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<!DOCTYPE html><html><body><div id="id1"></div><span id="id1"></span><strong>text</strong></body></html>'
+'<!DOCTYPE html><!--?xml encoding="utf-8" ?--><html><head><body>ml encoding="utf-8" ?--&gt;<html><head><strong>text</strong></head></html></body></head></html>'

/html5-dom-document-php/tests/Test.php:1514

ERRORS!
Tests: 51, Assertions: 105, Errors: 8, Failures: 21.
Script vendor/bin/phpunit handling the test event returned with error code 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions