doctrine-orm icon indicating copy to clipboard operation
doctrine-orm copied to clipboard

Bug in doctrine/orm 2.8.2 affects console commands

Open jankonas opened this issue 4 years ago • 3 comments

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?

jankonas avatar Feb 21 '21 13:02 jankonas

Great report. Will you prepare PR?

f3l1x avatar Feb 21 '21 13:02 f3l1x

Is good idea make workaround for bug?

petrparolek avatar Feb 21 '21 13:02 petrparolek

@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).

  1. 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;
	}
}
  1. Use it in config and use wrapped EntityManager in entityManagerHelper:
nettrine.orm:
	entityManagerDecoratorClass: MyEntityManagerDecorator

services:
	nettrine.orm.console.entityManagerHelper:
		arguments:
			- @nettrine.orm.entityManagerDecorator::getWrapped()

redwormik avatar Mar 17 '21 02:03 redwormik