php.net |  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
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
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
Have you experienced this issue?
Rate the importance of this bug to you:

 [2018-07-11 17:45 UTC] chealer at gmail dot com
Description:
------------
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.

https://3v4l.org/NFpRS shows that this persists in 7.3.0 alpha 1.

Test script:
---------------
<?php

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

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
)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-07-21 13:21 UTC] cmb@php.net
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] <https://gist.github.com/cmb69/76137ddce3a084c2893faa73be4c038f#file-verbose-diff>
[2] <https://gist.github.com/cmb69/76137ddce3a084c2893faa73be4c038f#file-out-txt>
 [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.
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Dec 16 08:01:26 2018 UTC