Skip to content
Snippets Groups Projects
Unverified Commit 69e817f5 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3477329 by phenaproxima, thejimbirch, b_sharpe: Recipe validation...

Issue #3477329 by phenaproxima, thejimbirch, b_sharpe: Recipe validation should always treat required modules as installed

(cherry picked from commit 81f055eb)
parent c9b15c8c
No related branches found
No related tags found
11 merge requests!10663Issue #3495778: Update phpdoc in FileSaveHtaccessLoggingTest,!10451Issue #3472458 by watergate, smustgrave: CKEditor 5 show blocks label is not translated,!103032838547 Fix punctuation rules for inline label suffix colon with CSS only,!10150Issue #3467294 by quietone, nod_, smustgrave, catch, longwave: Change string...,!10130Resolve #3480321 "Second level menu",!9936Issue #3483087: Check the module:// prefix in the translation server path and replace it with the actual module path,!9933Issue #3394728 by ankondrat4: Undefined array key "#prefix" and deprecated function: explode() in Drupal\file\Element\ManagedFile::uploadAjaxCallback(),!9914Issue #3451136 by quietone, gapple, ghost of drupal past: Improve...,!9882Draft: Issue #3481777 In bulk_form ensure the triggering element is the bulk_form button,!9839Issue #3445469 by pooja_sharma, smustgrave: Add additional test coverage for...,!9815Issue #3480025: There is no way to remove entity cache items
Pipeline #304358 passed
......@@ -268,14 +268,23 @@ private static function validateConfigActions(mixed $value, ExecutionContextInte
$configurator = new RecipeConfigurator($recipe_being_validated['recipes'] ?? [], $include_path);
/** @var \Drupal\Core\Extension\ModuleExtensionList $module_list */
$module_list = \Drupal::service('extension.list.module');
// The config provider must either be an already-installed module or theme,
// or an extension being installed by this recipe or a recipe it depends on.
$all_extensions = [
...array_keys(\Drupal::service('extension.list.module')->getAllInstalledInfo()),
...array_keys($module_list->getAllInstalledInfo()),
...array_keys(\Drupal::service('extension.list.theme')->getAllInstalledInfo()),
...$recipe_being_validated['install'] ?? [],
...$configurator->listAllExtensions(),
];
// Explicitly treat required modules as installed, even if Drupal isn't
// installed yet, because we know they WILL be installed.
foreach ($module_list->getAllAvailableInfo() as $name => $info) {
if (!empty($info['required'])) {
$all_extensions[] = $name;
}
}
if (!in_array($config_provider, $all_extensions, TRUE)) {
$context->addViolation('Config actions cannot be applied to %config_name because the %config_provider extension is not installed, and is not installed by this recipe or any of the recipes it depends on.', [
......
......@@ -8,6 +8,7 @@
use Drupal\Core\Recipe\RecipeFileException;
use Drupal\Core\Recipe\RecipePreExistingConfigException;
use Drupal\Core\Recipe\RecipeRunner;
use Drupal\FunctionalTests\Core\Recipe\RecipeTestTrait;
use Drupal\KernelTests\KernelTestBase;
/**
......@@ -16,6 +17,8 @@
*/
class RecipeTest extends KernelTestBase {
use RecipeTestTrait;
/**
* {@inheritdoc}
*/
......@@ -80,4 +83,19 @@ public function testExampleRecipe(): void {
$this->assertSame($this->config('text.settings')->get('default_summary_length'), 700);
}
public function testImplicitlyRequiredModule(): void {
$this->disableModules(['user']);
$recipe = $this->createRecipe([
'name' => 'Actions on config from required module',
'config' => [
'actions' => [
'user.role.authenticated' => [
'grantPermission' => 'access administration pages',
],
],
],
]);
$this->assertIsObject($recipe);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment