From: bisyarin at ukr dot net
Operating system: FreeBSD, Windows XP
PHP version: 5.2CVS-2009-02-17 (snap)
PHP Bug Type: DOM XML related
Bug description: Errors after writing to nodeValue parameter of an absent
previousSibling
Description:
------------
In one of my project's libraries I've forgot to check DOMNode's
"previousSibling" property for existence by accident. I think that DOM
extension should handle such situations gracefully. But after that, when I
try to create an array by assigning a value to unexistent key with square
bracket syntax, I get an error message:
PHP Fatal error: Cannot use object of type stdClass as array in
/xxx/yyy.php on line ZZZ
Reproduce code:
---------------
$xml = '<?xml
version="1.0"?><html><p><i>Hello</i></p><p><i>World!</i></p></html>';
$dom = new DOMDocument();
$dom->loadXML($xml);
$elements = $dom->getElementsByTagName('i');
foreach ($elements as $i) {
$i->previousSibling->nodeValue = '';
}
$arr[0] = 'Value';
print_r($arr);
Expected result:
----------------
Array
(
[0] => Value
)
Actual result:
--------------
PHP Fatal error: Cannot use object of type stdClass as array in
/usr/home/artem/comps/scripts/test.php on line 20
--
Edit bug report at http://bugs.php.net/?id=47430&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=47430&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=47430&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=47430&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=47430&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=47430&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=47430&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=47430&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=47430&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=47430&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=47430&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=47430&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=47430&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=47430&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=47430&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47430&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=47430&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=47430&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=47430&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=47430&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=47430&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=47430&r=mysqlcfg