|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-02-12 09:45 UTC] kalle@php.net
-Status: Open
+Status: Feedback
[2011-02-12 09:45 UTC] kalle@php.net
[2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 06 18:00:01 2025 UTC |
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