|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53973 storing SimpleXMLObject to class property does not always work (is null)
Submitted: 2011-02-09 16:13 UTC Modified: 2013-02-18 00:34 UTC
From: equinox at lichtspiele dot org Assigned:
Status: No Feedback Package: Class/Object related
PHP Version: 5.3.5 OS: debian squeeze/sid
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
29 + 45 = ?
Subscribe to this entry?

 [2011-02-09 16:13 UTC] equinox at lichtspiele dot org
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() {


$class = new ProjectXML();

The used code is very complex, so I reduced it to a minimum. The full code can be viewed here:

Expected result:

Actual result:
sometimes null
sometimes the SimpleXMLObject


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-12 09:45 UTC]
-Status: Open +Status: Feedback
 [2011-02-12 09:45 UTC]
Please supply a working script to reproduce this; the current have several faults:
 - There is no such class as SimpleXMLObject, simplexml uses SimpleXMLElement
 - The prototype for ProjectXML::foo() is not valid, typehinting should not use ( + ) around the hint
 - ProjectXML::foo() uses $xml_node, and the argument is named $xml
 - ProjectXML::foo() is called without the $search_criteria, producing a warning
 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jul 19 19:01:28 2024 UTC