From 55a120776d29e007e188bf9191c6e6daa385269f Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Fri, 30 Dec 2022 15:42:28 +0000 Subject: [PATCH] Issue #3087975 by smustgrave, kim.pepper, alexpott, Wim Leers, longwave: Add deprecation to InfoParserDynamic::__construct() to require root path --- core/lib/Drupal/Core/Extension/InfoParserDynamic.php | 3 +-- .../Drupal/Tests/Core/Extension/InfoParserUnitTest.php | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php index bcdb294f2c0..55c6ddd953e 100644 --- a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php +++ b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php @@ -26,8 +26,7 @@ class InfoParserDynamic implements InfoParserInterface { */ public function __construct(string $app_root = NULL) { if ($app_root === NULL) { - // @todo https://www.drupal.org/project/drupal/issues/3087975 Require - // $app_root argument. + @trigger_error('Calling InfoParserDynamic::__construct() without the $app_root argument is deprecated in drupal:10.1.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/3293709', E_USER_DEPRECATED); $app_root = \Drupal::hasService('kernel') ? \Drupal::root() : DRUPAL_ROOT; } $this->root = $app_root; diff --git a/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php b/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php index a7dad625b6d..1e03986aa87 100644 --- a/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php @@ -4,6 +4,7 @@ namespace Drupal\Tests\Core\Extension; use Drupal\Core\Extension\ExtensionLifecycle; use Drupal\Core\Extension\InfoParser; +use Drupal\Core\Extension\InfoParserDynamic; use Drupal\Core\Extension\InfoParserException; use Drupal\Tests\UnitTestCase; use org\bovigo\vfs\vfsStream; @@ -560,4 +561,12 @@ INFO; ]; } + /** + * @group legacy + */ + public function testDeprecation(): void { + $this->expectDeprecation('Calling InfoParserDynamic::__construct() without the $app_root argument is deprecated in drupal:10.1.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/3293709'); + new InfoParserDynamic(); + } + }