|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #76611 Printing DOMNode shows fake "(object value omitted)" strings
Submitted: 2018-07-11 17:45 UTC Modified: 2018-07-21 13:21 UTC
Avg. Score:4.5 ± 0.8
Reproduced:12 of 14 (85.7%)
Same Version:3 (25.0%)
Same OS:2 (16.7%)
From: chealer at gmail dot com Assigned:
Status: Open Package: DOM XML related
PHP Version: 7.2.7 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: chealer at gmail dot com
New email:
PHP Version: OS:


 [2018-07-11 17:45 UTC] chealer at gmail dot com
The DOM extension's DOMNode class seems to hide object properties when DOMNode objects are displayed.

For example, the following shows that print_r() presents the lastChild property as a string "(object value omitted)", but also that this property is in fact a DOMElement object when directly printed.

This affects Xdebug and makes it painful to debug the DOM extension. shows that this persists in 7.3.0 alpha 1.

Test script:

$dom = new DOMDocument();
$dom->loadHTML('<h1>Configuration</h1>', LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);

Actual result:
DOMDocument Object
    [doctype] => 
    [implementation] => (object value omitted)
    [documentElement] => (object value omitted)
    [actualEncoding] => 
    [encoding] => 
    [xmlEncoding] => 
    [standalone] => 1
    [xmlStandalone] => 1
    [version] => 
    [xmlVersion] => 
    [strictErrorChecking] => 1
    [documentURI] => 
    [config] => 
    [formatOutput] => 
    [validateOnParse] => 
    [resolveExternals] => 
    [preserveWhiteSpace] => 1
    [recover] => 
    [substituteEntities] => 
    [nodeName] => #document
    [nodeValue] => 
    [nodeType] => 13
    [parentNode] => 
    [childNodes] => (object value omitted)
    [firstChild] => (object value omitted)
    [lastChild] => (object value omitted)
    [previousSibling] => 
    [attributes] => 
    [ownerDocument] => 
    [namespaceURI] => 
    [prefix] => 
    [localName] => 
    [baseURI] => 
    [textContent] => Configuration
DOMElement Object
    [tagName] => h1
    [schemaTypeInfo] => 
    [nodeName] => h1
    [nodeValue] => Configuration
    [nodeType] => 1
    [parentNode] => (object value omitted)
    [childNodes] => (object value omitted)
    [firstChild] => (object value omitted)
    [lastChild] => (object value omitted)
    [previousSibling] => 
    [attributes] => (object value omitted)
    [ownerDocument] => (object value omitted)
    [namespaceURI] => 
    [prefix] => 
    [localName] => h1
    [baseURI] => 
    [textContent] => Configuration


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-07-21 13:21 UTC]
Changing this behavior would be as simple as applying this
patch[1], but I'm not sure that would be an improvement since the
output would be extremly verbose[2].

[1] <>
[2] <>
 [2018-09-14 08:55 UTC] naitsirch at e dot mail dot de
Yes, this is verbose, but otherwise it is hard to debug code that uses those objects. People who debug with print_r/var_dump can select concrete properties/attributes of the objects to get less output.

Please merge the patch.
 [2019-09-22 22:49 UTC]
The patch itself cannot be merged so easily, because it would instantly lead to out of memory for larger XML documents when they suddenly get fully printed to screen. The recursiveness of DOM nodes makes this very painful.

I propose we add a depth limit in a way if thats possible. For now the guard "(object value omitted)" is a good workaround though.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 08:01:28 2024 UTC