Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onFlush events with 2 or more dbal connections throw ErrorExceptions #93

Closed
trooney opened this issue Jul 12, 2012 · 2 comments
Closed

Comments

@trooney
Copy link

trooney commented Jul 12, 2012

Using Symfony 2.1 BETA. In configuration's with 2 connections, onFlush events written to (appDevDebugProject|appProd)Container.php contain calls to addEventListener. The method signature for the 2nd connection is incorrect. Changing the order the connection's are specified produces the incorrect signature on whatever happens to be the 2nd connection.

Compare the signatures for MysqlConnectionService and PlatConnectionService:

appDevDebugProjectContainer.php

protected function getDoctrine_Dbal_MysqlConnectionService()
{
    $c->addEventListener(array(0 => 'onFlush'), $this->get('nrc_notice.notice.notice_listener'));
}


protected function getDoctrine_Dbal_PlatConnectionService()
{
    $c->addEventListener(array(0 => array(0 => 'onFlush')), $this->get('nrc_notice.notice.notice_listener'));
}

Error Message

ErrorException: Warning: Illegal offset type in /Applications/MAMP/htdocs/checknet.local/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php line 115

in /Applications/MAMP/htdocs/checknet.local/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php line 115
at ErrorHandler->handle('2', 'Illegal offset type', '/Applications/MAMP/htdocs/checknet.local/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php', '115', array('events' => array(array('onFlush')), 'listener' => object(NoticeListener), 'hash' => '000000000bfa891500000000295a660c', 'event' => array('onFlush'))) in /Applications/MAMP/htdocs/checknet.local/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php line 115
at ContainerAwareEventManager->addEventListener(array(array('onFlush')), object(NoticeListener)) in /Applications/MAMP/htdocs/checknet.local/app/cache/dev/appDevDebugProjectContainer.php line 272
at appDevDebugProjectContainer->getDoctrine_Dbal_PlatConnectionService() in /Applications/MAMP/htdocs/checknet.local/app/bootstrap.php.cache line 194
at Container->get('doctrine.dbal.plat_connection') in /Applications/MAMP/htdocs/checknet.local/app/cache/dev/appDevDebugProjectContainer.php line 370
at appDevDebugProjectContainer->getDoctrine_Orm_PlatEntityManagerService() in /Applications/MAMP/htdocs/checknet.local/app/bootstrap.php.cache line 194
at Container->get('doctrine.orm.plat_entity_manager') in /Applications/MAMP/htdocs/checknet.local/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/ManagerRegistry.php line 35

My config.yml

doctrine:
    dbal:
        default_connection: mysql
        connections:
            mysql:
                 driver: etc...
            plat:
                 driver_class:   etc...

My services.yml

services:
  nrc_notice.notice.notice_listener:
     class: Some\Listener\Class
     arguments:
       container: '@service_container'
     tags:
        - { name: kernel.event_listener, event: nrc_notice.notice.change.approved, method: onNotify }

Similar pattern occurs while adding more connections:

protected function getDoctrine_Dbal_MysqlConnectionService()
{
    $c->addEventListener(array(0 => 'onFlush'), $this->get('nrc_notice.notice.notice_listener'));
}

protected function getDoctrine_Dbal_Mysql2ConnectionService()
{
    $c->addEventListener(array(0 => array(0 => 'onFlush')), $this->get('nrc_notice.notice.notice_listener'));
}

protected function getDoctrine_Dbal_PlatConnectionService()
{
    $c->addEventListener(array(0 => array(0 => array(0 => 'onFlush'))), $this->get('nrc_notice.notice.notice_listener'));
}
@trooney
Copy link
Author

trooney commented Jul 12, 2012

Just an extra note. I couldn't trace this, but it seems related to the Dependency Injection system:

  • (YamlFileLoader|XmlFileLoader) seemed to create the correct definitions
  • PHP Dumper dumped the incorrect definitions.

@trooney
Copy link
Author

trooney commented Jul 12, 2012

Original issue was re-opened. Closing this as it is now a duplicate.

@trooney trooney closed this as completed Jul 12, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant