php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47430 Errors after writing to nodeValue parameter of an absent previousSibling
Submitted: 2009-02-17 23:01 UTC Modified: 2009-03-13 13:45 UTC
From: bisyarin at ukr dot net Assigned: rrichards (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.2CVS-2009-02-17 (snap) OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bisyarin at ukr dot net
New email:
PHP Version: OS:

 

 [2009-02-17 23:01 UTC] 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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-17 23:54 UTC] 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-18 00:39 UTC] bisyarin at ukr dot net
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
 [2009-02-18 23:47 UTC] felipe@php.net
I can reproduce it using 5.3CVS.
 [2009-02-20 23:48 UTC] felipe@php.net
The problem is the 'retval = EG(uninitialized_zval_ptr);' in dom_read_property(), I guess that maybe would be more suitable throw an E_RECOVERABLE_ERROR there.

Assigned to maintainer.
 [2009-03-13 13:45 UTC] rrichards@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC