Bug #53973 [NEW]: storing SimpleXMLObject to class property does not always work (is null)

From: Date: Wed, 09 Feb 2011 15:13:08 +0000
Subject: Bug #53973 [NEW]: storing SimpleXMLObject to class property does not always work (is null)
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-158656@lists.php.net to get a copy of this message
From: Operating system: debian squeeze/sid PHP version: 5.3.5 Package: Class/Object related Bug Type: Bug Bug description:storing SimpleXMLObject to class property does not always work (is null) Description: ------------ The PHP-Version is 5.3.3-7 (was not able to select this version in the dropdown box) When storing a SimpleXMLObject to a class property the property is null sometimes (every 3rd - 5th call). According to this error, PHP seems to loose all object descriptors ($this) in *all* classes, which leads to misleading error messages like "trying to get property of non-object in ..", even if I checked $this to be an object 1 line before the error message happens (How can $this be not an object? I am always in object context). Current solution: When casting the SimpleXMLObject to an Array and storing it to the class property both problems do not appear. Test script: --------------- class ProjectXML { private $project_xml; public function foo((SimpleXMLObject) $xml, $search_criteria) { // search a specific node, save it to the class property and return true $this->project_xml = $xml_node; return true; } public function bar() { var_dump($this->project_xml); } } $class = new ProjectXML(); $class->foo(simplexml_load_file("/path/to/project.xml")); $class->bar(); /* The used code is very complex, so I reduced it to a minimum. The full code can be viewed here: http://quantum-framework.org/ProjectXML.class.phps */ Expected result: ---------------- SimpleXMLObject Actual result: -------------- sometimes null sometimes the SimpleXMLObject -- Edit bug report at http://bugs.php.net/bug.php?id=53973&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53973&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53973&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53973&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53973&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53973&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53973&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53973&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53973&r=needscript Try newer version: http://bugs.php.net/fix.php?id=53973&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53973&r=support Expected behavior: http://bugs.php.net/fix.php?id=53973&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53973&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53973&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53973&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53973&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=53973&r=dst IIS Stability: http://bugs.php.net/fix.php?id=53973&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53973&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53973&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53973&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53973&r=mysqlcfg

« previous php.bugs (#158656) next »