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

Wrong EventManager is injected when dbal.debug = true #7

Merged
merged 1 commit into from Apr 25, 2018

Conversation

3 participants
@uestla
Copy link
Contributor

uestla commented Apr 25, 2018

TL;DR

Wrong EventManager is injected when dbal.debug = true. In combination with nettrine/orm it causes EventManager mismatch in Connection and EntityManager.


Detailed Report

I'd like to see SQL queries on my Tracy panel. However after setting dbal.debug to true, I'm getting

Doctrine\ORM\ORMException: Cannot use different EventManager instances for EntityManager and Connection.

Steps to reproduce this bug:

1. Prepare the environment

composer create-project nette/web-project test
cd test
# increase PHP version in composer.json to >= 7.1 (7.1.16 in my case)
composer update

composer require contributte/console
# create bin/console as stated in documentation - https://github.com/contributte/console/blob/master/.docs/README.md#entrypoint

composer require nettrine/orm
mkdir app/Entity

2. Minimal configuration

Add following to app/config/config.neon:

extensions:
	console: Contributte\Console\DI\ConsoleExtension

	dbal: Nettrine\DBAL\DI\DbalExtension

	orm: Nettrine\ORM\DI\OrmExtension
	orm.annotations: Nettrine\ORM\DI\OrmAnnotationsExtension
	orm.console: Nettrine\ORM\DI\OrmConsoleExtension

dbal:
	debug: true

orm.annotations:
	paths:
		- %appDir%/Entity

3. Run ./bin/console

You should get

Doctrine\ORM\ORMException: Cannot use different EventManager instances for EntityManager and Connection.

This fix

Autowiring of EventManager is moved right after the default definition.

For Connection, the EventManager itself is autowired just like in nettrine/orm - see here.

@uestla uestla force-pushed the uestla:fix-debug-event-manager branch from 5941e04 to 6f91eef Apr 25, 2018

@coveralls

This comment has been minimized.

Copy link

coveralls commented Apr 25, 2018

Coverage Status

Coverage increased (+7.3%) to 28.655% when pulling 6f91eef on uestla:fix-debug-event-manager into 2ea563a on nettrine:master.

@f3l1x

This comment has been minimized.

Copy link
Member

f3l1x commented Apr 25, 2018

Thank you. Awesome report.

@f3l1x f3l1x merged commit 54c3011 into nettrine:master Apr 25, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+7.3%) to 28.655%
Details

@f3l1x f3l1x added the bug label Apr 25, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.