Req #76611 [Com]: Printing DOMNode shows fake "(object value omitted)" strings

From: Date: Sun, 22 Sep 2019 22:49:47 +0000
Subject: Req #76611 [Com]: Printing DOMNode shows fake "(object value omitted)" strings
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222881@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76611&edit=1 ID: 76611 Comment by: beberlei@php.net Reported by: chealer at gmail dot com Summary: Printing DOMNode shows fake "(object value omitted)" strings Status: Open Type: Feature/Change Request Package: DOM XML related PHP Version: 7.2.7 Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2018-09-14 08:55:11] 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. ------------------------------------------------------------------------ [2018-07-21 13:21:39] 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-07-11 17:45:26] 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 ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76611&edit=1

« previous php.bugs (#222881) next »