Problem/Motivation
When using the Recipe Installer Kit with a profile that defines default recipes but no optional recipes, the default recipes are never applied during installation.
This happens because:
- The
RecipesForm is configured in the profile's forms: list
RecipesForm::toInstallTask() skips the form when no optional recipes are defined (lines 17-20)
- When the form is skipped,
submitForm() is never called
- Therefore,
$install_state['parameters']['recipes'] is never populated with the default recipes
- In
Hooks::applyRecipes(), only required recipes and parameters['recipes'] are used - the default recipes are ignored
Steps to reproduce
- Create a profile with the following
info.yml configuration:
forms:
- '\Drupal\RecipeKit\Installer\Form\RecipesForm'
recipes:
required: []
default:
- drupal/my_starter_recipe
- Run the Drupal installer
- Notice that
my_starter_recipe is never applied
Proposed resolution
Modify Hooks::applyRecipes() to fall back to default recipes when parameters['recipes'] is not set.
Change from:
$recipes_to_apply = array_merge(
$install_state['profile_info']['recipes']['required'] ?? [],
$install_state['parameters']['recipes'] ?? [],
);
To:
$recipes_to_apply = array_merge(
$install_state['profile_info']['recipes']['required'] ?? [],
$install_state['parameters']['recipes'] ?? $install_state['profile_info']['recipes']['default'] ?? [],
);
This ensures that when no form populates parameters['recipes'] (because the form was skipped), the installation falls back to the default recipes defined in the profile's info.yml.
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #3
rajab natshahComment #5
phenaproximaThat looks great. Thanks! Merged into 1.x.