Uploaded image for project: 'Doctrine 1'
  1. Doctrine 1
  2. DC-190

Fatal error while connecting after an reset of the Doctrine_Manager


    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.0-ALPHA3, 1.2.0-BETA1
    • Fix Version/s: 1.2.0-BETA2
    • Component/s: Attributes
    • Labels:
    • Environment:
      osx10.6.1, php5.3.0


      Fatal error: Call to a member function onOpen() on a non-object in ...../Doctrine/Connection.php on line 221

      which is $this->getAttribute(Doctrine_Core::ATTR_LISTENER)->onOpen($this);

      The Doctrine_Core::ATTR_LISTENER attribute is not set in the connection nore in the manager... This is because Doctrine_Manager::resetInstance does remove all attributes but Doctrine_Manager::setDefaultAttributes does not allow to set the default attributes twice.

      This method can only run once, because it use a local static $init variable and since Doctrine_Manager is a Singleton the init value should stored within the instance.

      What happens :
      1. In Doctrine_Manager::setDefaultAttributes() the Doctrine_Core::ATTR_LISTENER is set to new Doctrine_EventListener().
      2. A connection get its attributes from the manager when not available in the connection.
      3. When Doctrine_Manager::reset() is called the attributes are gone and should be set again...
      4. However because the Doctrine_Manager::setDefaultAttibutes method only can run once (a check is set in a static local boolean) the listener is not recreated and thus subsequent connections will fatally fail

      patch by
      A fix is simple and I have it running locally...

      1. add an private $_inited or $_defaultAttributesSet property to Doctrine_Manager, defaults to false;
      2. on Doctrine_Manager::reset reset it to its default (false)
      3. on Doctrine_Manager::setDefaultAttibutes do nothing when the property equals true, but when the property is false proceed with setting the default attributes...


        There are no comments yet on this issue.


          • Assignee:
            jwage Jonathan H. Wage
            bas Bas K
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: