#47430 [Fbk->Opn]: Errors after writing to nodeValue parameter of an absent previousSibling
| From: | bisyarin at ukr dot net | Date: | Wed, 18 Feb 2009 00:39:02 +0000 |
| Subject: | #47430 [Fbk->Opn]: Errors after writing to nodeValue parameter of an absent previousSibling | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-133940@lists.php.net to get a copy of this message | ||
ID: 47430
User updated by: bisyarin at ukr dot net
Reported By: bisyarin at ukr dot net
-Status: Feedback
+Status: Open
Bug Type: DOM XML related
Operating System: *
PHP Version: 5.2CVS-2009-02-17 (snap)
New Comment:
I've tried PHP 5.2.9RC3-dev on windows and FreeBSD and still the same.
Output from my win-machine:
version:
PHP 5.2.9RC3-dev (cli) (built: Feb 17 2009 23:39:59)
Error message:
PHP Fatal error: Cannot use object of type stdClass as array in
D:\artem\phpDOMBagTest.php on line 19
Output from my FreeBSD machine:
version:
PHP 5.2.9RC3-dev (cli) (built: Feb 18 2009 02:14:56)
Error message:
Fatal error: Cannot use object of type stdClass as array in
/usr/home/artem/comps/scripts/phpDOMBagTest.php on line 19
Previous Comments:
------------------------------------------------------------------------
[2009-02-17 23:54:19] jani@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
------------------------------------------------------------------------
[2009-02-17 23:01:30] bisyarin at ukr dot net
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 this bug report at http://bugs.php.net/?id=47430&edit=1