doctrine-orm
doctrine-orm copied to clipboard
Bug in doctrine/orm 2.8.2 affects console commands
There was a BC-break introduced in doctrine/orm 2.8.2 - AbstractCommand requires EntityManager: https://github.com/doctrine/orm/issues/8488.
When running db-related commands, following error is thrown:
ErrorException: assert(): assert($em instanceof EntityManager) failed in vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php:56
It is already fixed (https://github.com/doctrine/orm/pull/8493), so I assume 2.8.3 will be ok.
Maybe it would be worth it to add conflict with 2.8.2 into composer.json?
Great report. Will you prepare PR?
Is good idea make workaround for bug?
@petrparolek I found a workaround, but it is not very nice (and possibly breaks if you use entityManagerHelper and depend on your EntityManagerDecorator in custom commands).
- Create a new EntityManagerDecorator (or add getWrapped method to it):
class MyEntityManagerDecorator extends Nettrine\ORM\EntityManagerDecorator
{
public function getWrapped(): Doctrine\ORM\EntityManagerInterface
{
return $this->wrapped;
}
}
- Use it in config and use wrapped EntityManager in entityManagerHelper:
nettrine.orm:
entityManagerDecoratorClass: MyEntityManagerDecorator
services:
nettrine.orm.console.entityManagerHelper:
arguments:
- @nettrine.orm.entityManagerDecorator::getWrapped()