#45879 [NEW]: Cannot clone objects due to 'zend.ze1_compatibility_mode' on NodeList::item

[email protected] ("olivier dot berger at it-sudparis dot eu")
Newsgroups php.bugs
Message-ID <[email protected]>
From:             olivier dot berger at it-sudparis dot eu
Operating system: Debian lenny
PHP version:      5.2.6
PHP Bug Type:     DOM XML related
Bug description:  Cannot clone objects due to 'zend.ze1_compatibility_mode' on NodeList::item

Description:
------------
When zend.ze1_compatibility_mode is on, there are clone problems when
iterating over the DOMNodelist items

With the following code, I get :
Fatal error: Cannot clone object of class DOMText due to
'zend.ze1_compatibility_mode' for instance

Reproduce code:
---------------
<?php
ini_set('zend.ze1_compatibility_mode', true);
$doc =& new DOMDocument();
$success = $doc->load('/tmp/test.xml');
$root =& $doc->documentElement;
$nodeList = &$doc->documentElement->childNodes;
for ($i = 0; $i < $nodeList->length; ++$i) {
    $node = &$nodeList->item($i);
    echo "$i - ";
    $nodeName = $node->nodeName;
    echo "$nodeName :";
    $nodeValue = $node->nodeValue;
    echo "$nodeValue <br/>";
}


Expected result:
----------------
I would expect it to display the XML file's contents as without
zend.ze1_compatibility_mode (in which case it works)

Actual result:
--------------
I get "Cannot clone object of class DOMText" wether with :
$node = &$nodeList->item($i);
or :
$node = $nodeList->item($i);

a :
foreach ($nodeList as $node) {
    echo $node->nodeName;
    echo $node->nodeValue;
}
won't work either.

I guess that the internals of DOMNodelist::item tries to clone them
instead of returning them by address, then.

Note that :
for ($i = 0; $i < $nodeList->length; ++$i) {
    echo "$i - ";
    $nodeName = $nodeList->item($i)->nodeName;
    echo "$nodeName :";
    $nodeValue = $nodeList->item($i)->nodeValue;
    echo "$nodeValue <br/>";
}
seems to work, though.

-- 
Edit bug report at http://bugs.php.net/?id=45879&edit=1
-- 
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45879&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45879&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45879&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=45879&r=fixedcvs
Fixed in release:             http://bugs.php.net/fix.php?id=45879&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=45879&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=45879&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=45879&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=45879&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=45879&r=notwrong
Not enough info:              http://bugs.php.net/fix.php?id=45879&r=notenoughinfo
Submitted twice:              http://bugs.php.net/fix.php?id=45879&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=45879&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=45879&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=45879&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=45879&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=45879&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=45879&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=45879&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=45879&r=mysqlcfg
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.