From 55a120776d29e007e188bf9191c6e6daa385269f Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
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 bcdb294f2c09..55c6ddd953ee 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 a7dad625b6d7..1e03986aa878 100644
--- a/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Extension/InfoParserUnitTest.php
@@ -4,6 +4,7 @@
 
 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 @@ public function providerLifecycleLink() {
     ];
   }
 
+  /**
+   * @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();
+  }
+
 }
-- 
GitLab