diff --git a/core/.deprecation-ignore.txt b/core/.deprecation-ignore.txt index 30ceb01a7d690a2712193602926dc21d4a21b43d..8b2d2cf4a8df1142d0cc05f2ad4a419f5175469b 100644 --- a/core/.deprecation-ignore.txt +++ b/core/.deprecation-ignore.txt @@ -37,8 +37,12 @@ %Expecting E_WARNING and E_USER_WARNING is deprecated and will no longer be possible in PHPUnit 10% %Expecting E_ERROR and E_USER_ERROR is deprecated and will no longer be possible in PHPUnit 10% -# Temporarily for testing Symfony 6.4. +# Symfony 6.4. %Since symfony/dependency-injection 6.4: "Symfony\\Component\\DependencyInjection\\ContainerAwareTrait" is deprecated, use dependency injection instead.% -%The ".*" class uses "Symfony\\Component\\DependencyInjection\\ContainerAwareTrait" that is deprecated since Symfony 6.4, use dependency injection instead.% -%The ".*" class implements "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.% -%The ".*" interface extends "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.% +%The "Drupal\\Core\\Logger\\LoggerChannelFactory" class implements "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.% +%The "Drupal\\Core\\Logger\\LoggerChannelFactory" class uses "Symfony\\Component\\DependencyInjection\\ContainerAwareTrait" that is deprecated since Symfony 6.4, use dependency injection instead.% +%The "Drupal\\Core\\Queue\\QueueFactory" class implements "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.% +%The "Drupal\\Core\\Queue\\QueueFactory" class uses "Symfony\\Component\\DependencyInjection\\ContainerAwareTrait" that is deprecated since Symfony 6.4, use dependency injection instead.% +%The "Drupal\\Tests\\Core\\Controller\\MockContainerAware" class implements "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.% +%The "Drupal\\Tests\\Core\\DependencyInjection\\DependencySerializationTestDummy" class implements "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.% +%The "Drupal\\Tests\\Core\\Utility\\MockContainerAware" class implements "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.% diff --git a/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php b/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php index 1efab6b0c967506170cf62cc1c8f8ca03ee569e4..66ce3d5e1d64ba1e0bdb3fb274a82f859dc7a2e7 100644 --- a/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php +++ b/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php @@ -46,6 +46,7 @@ public function getInstanceFromDefinition($definition) { } if ($instance instanceof ContainerAwareInterface) { + @trigger_error('Implementing \Symfony\Component\DependencyInjection\ContainerAwareInterface is deprecated in drupal:10.3.0 and it will be removed in drupal:11.0.0. Implement \Drupal\Core\DependencyInjection\ContainerInjectionInterface and use dependency injection instead. See https://www.drupal.org/node/3428661', E_USER_DEPRECATED); $instance->setContainer($this->container); } diff --git a/core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php b/core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php index d58ff9d2ddb400c4a55f0f07468ba0ee8f165c3a..4e4ec81a6ca9402f88c80a5ebade3e87d060b36b 100644 --- a/core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php +++ b/core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php @@ -52,8 +52,12 @@ protected function setUp(): void { * Tests createController(). * * @dataProvider providerTestCreateController + * @group legacy */ - public function testCreateController($controller, $class, $output) { + public function testCreateController($controller, $class, $output, string $deprecation = NULL) { + if ($deprecation) { + $this->expectDeprecation($deprecation); + } $this->container->set('some_service', new MockController()); $result = $this->controllerResolver->getControllerFromDefinition($controller); $this->assertCallableController($result, $class, $output); @@ -71,7 +75,12 @@ public static function providerTestCreateController() { // Tests a class with injection. ['Drupal\Tests\Core\Controller\MockContainerInjection::getResult', 'Drupal\Tests\Core\Controller\MockContainerInjection', 'This used injection.'], // Tests a ContainerAware class. - ['Drupal\Tests\Core\Controller\MockContainerAware::getResult', 'Drupal\Tests\Core\Controller\MockContainerAware', 'This is container aware.'], + [ + 'Drupal\Tests\Core\Controller\MockContainerAware::getResult', + 'Drupal\Tests\Core\Controller\MockContainerAware', + 'This is container aware.', + 'Implementing \Symfony\Component\DependencyInjection\ContainerAwareInterface is deprecated in drupal:10.3.0 and it will be removed in drupal:11.0.0. Implement \Drupal\Core\DependencyInjection\ContainerInjectionInterface and use dependency injection instead. See https://www.drupal.org/node/3428661', + ], ]; } @@ -95,8 +104,12 @@ public function testCreateControllerInvalidName() { * Tests getController(). * * @dataProvider providerTestGetController + * @group legacy */ public function testGetController($attributes, $class, $output = NULL) { + if ($class) { + $this->expectDeprecation('Implementing \Symfony\Component\DependencyInjection\ContainerAwareInterface is deprecated in drupal:10.3.0 and it will be removed in drupal:11.0.0. Implement \Drupal\Core\DependencyInjection\ContainerInjectionInterface and use dependency injection instead. See https://www.drupal.org/node/3428661'); + } $request = new Request([], [], $attributes); $result = $this->controllerResolver->getController($request); if ($class) { diff --git a/core/tests/Drupal/Tests/Core/Utility/CallableResolverTest.php b/core/tests/Drupal/Tests/Core/Utility/CallableResolverTest.php index eedf6a3d7151e6f70471150793071bb0c6e0cc75..c12d2687abdd2db5ab991039129d148813dea911 100644 --- a/core/tests/Drupal/Tests/Core/Utility/CallableResolverTest.php +++ b/core/tests/Drupal/Tests/Core/Utility/CallableResolverTest.php @@ -42,8 +42,12 @@ protected function setUp(): void { /** * @dataProvider callableResolverTestCases * @covers ::getCallableFromDefinition + * @group legacy */ - public function testCallbackResolver($definition, $result) { + public function testCallbackResolver($definition, $result, string $deprecation = NULL) { + if ($deprecation) { + $this->expectDeprecation($deprecation); + } $argument = 'bar'; $this->assertEquals($result . '+' . $argument, $this->resolver->getCallableFromDefinition($definition)($argument)); } @@ -98,6 +102,7 @@ function ($suffix) { 'Non-static function, instantiated by class resolver, container aware' => [ '\Drupal\Tests\Core\Utility\MockContainerAware::getResult', 'Drupal\Tests\Core\Utility\MockContainerAware::getResult', + 'Implementing \Symfony\Component\DependencyInjection\ContainerAwareInterface is deprecated in drupal:10.3.0 and it will be removed in drupal:11.0.0. Implement \Drupal\Core\DependencyInjection\ContainerInjectionInterface and use dependency injection instead. See https://www.drupal.org/node/3428661', ], 'Service notation' => [ 'test_service:method',