Issue #3087975 by smustgrave, kim.pepper, alexpott, Wim Leers, longwave: Add deprecation to InfoParserDynamic::__construct() to require root path

merge-requests/2928/merge
Alex Pott 2022-12-30 15:42:28 +00:00
parent 15744364dc
commit 55a120776d
No known key found for this signature in database
GPG Key ID: BDA67E7EE836E5CE
2 changed files with 10 additions and 2 deletions

View File

@ -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;

View File

@ -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();
}
}