Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 292538

Service autowiring depends on symfony/config that is missing from composer (at least dev)

$
0
0

Problem/Motivation

Playing around with service autowiring, I incurrred into

PHPUnit 9.5.26 by Sebastian Bergmann and contributors.

Testing Drupal\Tests\file_mdm_exif\Kernel\FileMetadataExifTest
ERE                                                                 3 / 3 (100%)E

Time: 00:01.383, Memory: 4.00 MB

There were 3 errors:

1) Drupal\Tests\file_mdm_exif\Kernel\FileMetadataExifTest::testExifPlugin
Error: Class "Symfony\Component\Config\Resource\ClassExistenceResource" not found

/var/www/html/vendor/symfony/dependency-injection/Compiler/AutowirePass.php:526
/var/www/html/vendor/symfony/dependency-injection/Compiler/AutowirePass.php:505
[...]

This happens when autowiring cannot determine a unique service to be injected as an argument. Which is an error, yes, but the error reported here is that symfony/config is missing as a dependency (at least a dev one).

If I add the package to my codebase, I end up with a much better understandable error:

PHPUnit 9.5.26 by Sebastian Bergmann and contributors.

Testing Drupal\Tests\file_mdm_exif\Kernel\FileMetadataExifTest
ERE                                                                 3 / 3 (100%)E

Time: 00:02.070, Memory: 4.00 MB

There were 3 errors:

1) Drupal\Tests\file_mdm_exif\Kernel\FileMetadataExifTest::testExifPlugin
Symfony\Component\DependencyInjection\Exception\RuntimeException: Cannot autowire service "file_metadata_manager": argument "$logger" of method "Drupal\file_mdm\FileMetadataManager::__construct()" references interface "Psr\Log\LoggerInterface" but no such service exists. You should maybe alias this interface to one of these existing services: "logger.channel.default", "logger.channel.php", "logger.channel.image", "logger.channel.cron", "logger.channel.file", "logger.channel.form", "logger.channel.security", "logger.channel.system", "logger.channel.file_mdm".

/var/www/html/vendor/symfony/dependency-injection/Compiler/DefinitionErrorExceptionPass.php:51
/var/www/html/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php:80
/var/www/html/vendor/symfony/dependency-injection/Compiler/DefinitionErrorExceptionPass.php:29
/var/www/html/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php:44
/var/www/html/vendor/symfony/dependency-injection/Compiler/Compiler.php:73
[...]

Proposed resolution

Add symfony/config:^6.2 package to composer.json (at least in the dev section if not in the runtime one).

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 292538

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>