- Issue created by @kksandr
- Merge request !8969Issue #3464426: fixed AutowireTrait behavior for nullable types → (Open) created by Unnamed author
- Status changed to Needs work
12 months ago 12:14pm 29 July 2024 - 🇺🇸United States jrockowitz Brooklyn, NY
I ran into this exact issue when dealing with an optional dependency. The suggested solution makes sense to me.
- First commit to issue fork.
- 🇺🇸United States smustgrave
1) Drupal\KernelTests\Core\DependencyInjection\AutowireTest::testAutowireInvalidDependency Symfony\Component\DependencyInjection\Exception\AutowiringFailedException: Cannot autowire service "Drupal\KernelTests\Core\DependencyInjection\InvalidServiceInterface": argument "$service" of method "Drupal\KernelTests\Core\DependencyInjection\InvalidOptionalDependencyController::_construct()", you should configure its value explicitly. /builds/issue/drupal-3464426/core/lib/Drupal/Core/DependencyInjection/AutowireTrait.php:37 /builds/issue/drupal-3464426/core/tests/Drupal/KernelTests/Core/DependencyInjection/AutowireTest.php:191 ERRORS! Tests: 4, Assertions: 7, Errors: 1.
Seems like good test coverage
- First commit to issue fork.
- 🇬🇧United Kingdom alexpott 🇪🇺🌍
I moved the test to be alongside where the exception is tested and I improved the test to check for more things.
Committed and pushed 8cd685b9f10 to 11.x and 86a448df9c8 to 11.2.x and 2f93f58bd14 to 10.6.x and fc389ed0fc6 to 10.5.x. Thanks!
Backporting to 10.5.x as a bugfix and I've run the tests there and everything is fine.
-
alexpott →
committed fc389ed0 on 10.5.x
Issue #3464426 by dcam, kksandr, alexpott: AutowireTrait and autowire...
-
alexpott →
committed fc389ed0 on 10.5.x
-
alexpott →
committed 2f93f58b on 10.6.x
Issue #3464426 by dcam, kksandr, alexpott: AutowireTrait and autowire...
-
alexpott →
committed 2f93f58b on 10.6.x
-
alexpott →
committed 86a448df on 11.2.x
Issue #3464426 by dcam, kksandr, alexpott: AutowireTrait and autowire...
-
alexpott →
committed 86a448df on 11.2.x
-
alexpott →
committed 8cd685b9 on 11.x
Issue #3464426 by dcam, kksandr, alexpott: AutowireTrait and autowire...
-
alexpott →
committed 8cd685b9 on 11.x