|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77894 DOMNode::C14N() very slow on generated DOMDocuments even after normalisation
Submitted: 2019-04-15 10:19 UTC Modified: -
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: luxian dot m at gmail dot com Assigned:
Status: Open Package: DOM XML related
PHP Version: 7.3.4 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2019-04-15 10:19 UTC] luxian dot m at gmail dot com
Calling DOMNode::C14N() is way slower on DOMDocument objects that are created on the fly compared to DOMDocuments loaded from a string file.

Calling DOMDocument::normalizeDocument() doesn't make a difference despite the documentation stating: "This method acts as if you saved and then loaded the document, putting the document in a "normal" form."

But in the end it's still way faster to get the XML string and load it in a new DOMDocument - which is counter intuitive.

Code to demonstrate this can be found here: (limited to 200 items to not abuse the platform)

If you run the example code with 500 items you should get something like this:

Testing with 500 items
Generated DOM… 2.56458 seconds
Generated DOM with normalizeDocument()… 2.60349 seconds
Export and re-import DOM… 0.06695 seconds

Test script:

Expected result:
// should be the same as

Actual result:
40x worse performance when calling C14N() 


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Mar 23 06:03:38 2023 UTC