title: intermittent 'Attempt to assign property of non-object' on requests / unable to set object properties via $this
body: <p>I'm getting a rather strange intermittent error on a webapp I'm working on, that only triggers after certain circumstances. Once a particularly long processing page is executed (running through, retrieving and sorting 100000+ records), every page load since is failing with several errors like the following on any of the singleton objects used:</p>
  
  <p>PHP Warning:  Attempt to assign property of non-object in E:\tracking\lib\Controller\ControllerChainManager.class.php on line 33</p>
  
  <p>The relevant section of code is as follows: (Line 33 marked with an arrow).</p>
  
  <pre><code>class ControllerManager {
  private static $Instance;
  private $CurrentController = 0;
  private $ControllerArray;
  private $ControllerArrayIndex = 0;
  
  /**
   * Constructor
   * @return null;
   */
  private function __construct() {
      $this-&gt;ControllerArray = array(); &lt;-- LINE 33
      return;
  }
  
  /**
   * Singleton instance function
   * @return ControllerManager;
   */
  public static function Inst() {
      if (!isset(self::$Instance)) {
          $c = __CLASS__;
          self::$Instance = new $c;
      }
      return self::$Instance;
  }
  
  //*** snip the rest of the class definition ***
  </code></pre>
  
  <p>Now, this file is included in every request, but once the bad request is made, these errors will keep occurring (eventually leading to fatal errors down the line) until the Apache server restarts. If the same request is made using a smaller data set, the error doesn't occur and the system carries on as normal.</p>
  
  <p>Nothing seems to be turning up as relevant searching on the error text given, <strike>and the fact that the problem is failing only on singleton-pattern instances might be a clue</strike>, but I can't for the life of me figure what's going on.</p>
  
  <p>Server is PHP 5.3.</p>
  
  <p>Anyone ever seen an error like this before? It's somewhat stumping me.</p>
  
  <p>Edit: An additional trawling through the logs is now revealing another class showing this error, but it's NOT a singleton this time.</p>
  
  <pre><code>class ControllerChainData {
  public $Action;
  public $Controller;
  public $Vars;
  
  public function __construct($controller,$action,$vars = null) {
      $this-&gt;Controller = $controller; //&lt;-- 10
      $this-&gt;Action = $action; //&lt;-- 11
      $this-&gt;Vars = $vars; //&lt;-- 12
  }
  } 
  </code></pre>
  
  <p>Resulting in... </p>
  
  <ul>
  <li><p>PHP Warning:  Attempt to assign property of non-object in E:\tracking\lib\Controller\ControllerChainManager.class.php on line 10</p></li>
  <li><p>PHP Warning:  Attempt to assign property of non-object in E:\tracking\lib\Controller\ControllerChainManager.class.php on line 11</p></li>
  <li><p>PHP Warning:  Attempt to assign property of non-object in E:\tracking\lib\Controller\ControllerChainManager.class.php on line 12</p></li>
  </ul>
  
  <p>whenever an object of class ControllerChainData is instantiated.</p>
  
  <p>Edit 2: In response to a comment below, CCD is called from the following method of the ControllerChainManager class:</p>
  
  <pre><code>public function RegisterControllerIntoChain ($controller, $action, $vars = null) {          
  $contpath = 'controllers/' . $controller . '/' . $controller . '.cont.php';
      if (file_exists($contpath)) {
          include_once($contpath);
          $this-&gt;ControllerArray[$this-&gt;ControllerArrayIndex++] = new ControllerChainData($controller,$action,$vars);
          return true;
      }
      return false;
  }
  </code></pre>
  
  <p>Edit 3: Looks like this previous stackOverflow post is relevant / may be the same bug:</p>
  
  <p><a href="https://stackoverflow.com/questions/4188125/non-deterministic-object-reference-bug-in-php-5-3-x">Non-deterministic object reference bug in PHP 5.3.X</a></p>
  
  <p>Edit 3a:</p>
  
  <p>This error report is describing my exact problem: <a href="http://bugs.php.net/bug.php?id=50027" rel="nofollow noreferrer">http://bugs.php.net/bug.php?id=50027</a> (found from prior SO post)
  I'm going to update PHP on the server as soon as possible, I'll post information on if this solves the problem.</p>