persistence: Fatal error when upgrading to 2.0.4 and using ORM

BC Break Report

When executing cache:clear after composer update there is PHP fatal error.

PHP Fatal error:  Declaration of Doctrine\ORM\MappingClassMetadataFactory::wakeupReflection(Doctrine\Common\Persistence\Mapping\ClassMetadata $class, Doctrine\Common\Persistence\Mapping\ReflectionService $reflService) must be compatible with Doctrine\Persistence\MappingAbstractClassMetadataFactory::wakeupReflection(Doctrine\Persistence\Mapping\ClassMetadata $class, Doctrine\Persistence\Mapping\ReflectionService $reflService) in /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php on line 797

PHP Stack trace:
1. {main}() /var/www/html/bin/console:0
2. Symfony\Bundle\FrameworkBundle\Console\Application->run() /var/www/html/bin/console:44
3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /var/www/html/vendor/symfony/console/Application.php:148
4. Symfony\Bundle\FrameworkBundle\Console\Application->registerCommands() /var/www/html/vendor/symfony/framework-bundle/Console/Application.php:65
5. App\Kernel->boot() /var/www/html/vendor/symfony/framework-bundle/Console/Application.php:159
6. App\Kernel->initializeContainer() /var/www/html/vendor/symfony/http-kernel/Kernel.php:136
7. Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp() /var/www/html/vendor/symfony/http-kernel/Kernel.php:658
8. ContainerEPFlGxJ\srcApp_KernelDevDebugContainer->{closure:/var/www/html/var/cache/dev/ContainerEPFlGxJ/getCacheWarmerService.php:12-25}() /var/www/html/vendor/symfony/http-kernel/CacheWarmer/CacheWarmerAggregate.php:89
9. ContainerEPFlGxJ\srcApp_KernelDevDebugContainer->load() /var/www/html/var/cache/dev/ContainerEPFlGxJ/getCacheWarmerService.php:17
10. require() /var/www/html/var/cache/dev/ContainerEPFlGxJ/srcApp_KernelDevDebugContainer.php:785
11. ContainerEPFlGxJ\srcApp_KernelDevDebugContainer->getValidator_BuilderService() /var/www/html/var/cache/dev/ContainerEPFlGxJ/getValidator_Mapping_CacheWarmerService.php:13
12. ContainerEPFlGxJ\srcApp_KernelDevDebugContainer->getDoctrine_Orm_DefaultEntityManagerService() /var/www/html/var/cache/dev/ContainerEPFlGxJ/srcApp_KernelDevDebugContainer.php:3127
13. Doctrine\ORM\EntityManager::create() /var/www/html/var/cache/dev/ContainerEPFlGxJ/srcApp_KernelDevDebugContainer.php:1111
14. Doctrine\ORM\EntityManager->__construct() /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:873
15. spl_autoload_call() /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:159
16. Symfony\Component\Debug\DebugClassLoader->loadClass() /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:159

In ClassMetadataFactory.php line 797:
Compile Error: Declaration of Doctrine\ORM\Mapping\ClassMetadataFactory::wakeupReflection(Doctrine\Common\Persistence\Mapping\ClassMetadata $class, Doctrine\Common\Persistence\Mapping\ReflectionService $reflService) must be compatible with Doctrine\Persistence\Mapping\AbstractClassMetadataFactory::wakeupReflection(Doctrine\Persistence\Mapping\ClassMetadata $class, Doctrine\Persistence\Mapping\ReflectionService $reflService)
Q A
BC Break yes
Version 2.0.4

Package mongodb-odm is provided through doctrine/mongodb-odm-bundle (^4.0). Adding fixed "doctrine/mongodb-odm": "2.0.3" to composer as a temporary fix does the trick.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (9 by maintainers)

Commits related to this issue

Most upvoted comments

I can confirm that all works fine now.

Yup, changing line 74 to

interface_exists(\Doctrine\Common\Persistence\Mapping\ReflectionService::class);

fixed it. Or at least clearing the cache