DoctrineBundle: fails on clearing cache on PHP 7.2.20 if twig/twig is not installed

PHP 7.2.20 fixes bug related to autoloading non-existing interfaces: https://bugs.php.net/bug.php?id=76980

Steps to reproduce: Use PHP 7.2.20. Require this bundle (v1.11.2) in Symfony v4.3. Make sure twig/twig is not required and is not a transitive dependency of any of other packages (e.g. symfony/twig-bundle). Attempt to clear cache (php bin/console cache:clear).

Expected result: Cache cleared successfully.

Actual result: PHP Fatal error: During class fetch: Uncaught ReflectionException: Class Twig\Extension\AbstractExtension not found in /path/to/project/vendor/doctrine/doctrine-bundle/Twig/DoctrineExtension.php:13 Stack trace: (…)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (7 by maintainers)

Most upvoted comments

I did a quick test with php 7.3.8RC1. Cache warmup on @someniatko’s reproducer completed without errors.

As per https://github.com/php/php-src/commit/22ed362810c1b3a5ecb54ebd1d50d804c7fc3159, the change in PHP that causes this error will be reverted in the next patch releases for 7.2 and 7.3. For PHP 7.4, there needs to be a different solution. However, since this is caused by the DI component, I’d like to wait before working around this here. If this can’t be solved in the DI component (which could always handle such incomplete services when they aren’t used), then we’ll have to change our service configs to only create services that have all their dependencies set. I’m closing this for now until we find a resolution for it in https://github.com/symfony/symfony/issues/32395.

@someniatko PHP 7.3.7-1 worked!
php7.3 bin/console cache:clear [OK] Cache for the "dev" environment (debug=true) was successfully cleared.

PHP 7.2.20-1 not worked!