#1595: Event listener preConnect does not always trigger
---------------------------------------+------------------------------------
 Reporter:  demc                       |       Owner:  jwage  
     Type:  defect                     |      Status:  new    
 Priority:  minor                      |   Milestone:  Unknown
Component:  Listeners                  |     Version:  1.0.3  
 Keywords:  preconnect event listener  |    Has_test:  0      
 Mystatus:  Pending Core Response      |   Has_patch:  0      
---------------------------------------+------------------------------------
 From symfony trac as requested by JW.

 I have event listener DatabaseConnectionListener.class.php


 {{{
 <?php

 class DatabaseConnectionListener extends Doctrine_EventListener
 {
     public function preConnect(Doctrine_Event $event)
     {
                         $invoker = $event->getInvoker();

                         $invoker->setOption('username',
 Tools::decrypt($invoker->getOption('username')));
                         $invoker->setOption('password',
 Tools::decrypt($invoker->getOption('password')));
     }
 }
 }}}

 which is registered in config/doctrine.yml as


 {{{
 all:
   listeners: [DatabaseConnectionListener]
 }}}


 and it works as expected almost all the time. The problem is that it
 doesn't trigger when '''./symfony doctrine:rebuild-db --force frontend'''
 is called but it does work when calling '''./symfony doctrine:build-sql
 frontend'''

 So both tasks connect to DB but rebuild-db doesn't trigger preConnect
 event - consequently in my case doctrine fails to connect to DB coz u/p
 from database.yml are not decrypted.

 ----

 By JW:
 ''The problem here is actually a problem with Doctrine. The issue is that
 the rebuild-db task drops the database, and recreates it. To do this, the
 connection is used to drop the database and the connection is destroyed
 and recreated with the newly created database, since the connection is
 destroyed and recreated, it doesn't maintain anything it had attached to
 it. Can you create a ticket for this in the Doctrine trac?
 ''

-- 
Ticket URL: <http://trac.doctrine-project.org/ticket/1595>
Doctrine <http://www.phpdoctrine.org>
PHP Doctrine Object Relational Mapper
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"doctrine-svn" group.
 To post to this group, send email to [email protected]
 To unsubscribe from this group, send email to [EMAIL PROTECTED]
 For more options, visit this group at 
http://groups.google.co.uk/group/doctrine-svn?hl=en-GB
-~----------~----~----~----~------~----~------~--~---

Reply via email to