Issue #3495305 by phenaproxima: Recipes that depend on other recipes break RecipeInputFormTrait

(cherry picked from commit ac347da742)
merge-requests/10634/merge
Alex Pott 2024-12-20 18:41:12 +00:00
parent 75edbfda93
commit 379ebd46fc
No known key found for this signature in database
GPG Key ID: BDA67E7EE836E5CE
3 changed files with 12 additions and 6 deletions

View File

@ -25,11 +25,11 @@ final class InputConfigurator {
private array $data = [];
/**
* The collected input values, or NULL if none have been collected yet.
* The collected input values.
*
* @var mixed[]|null
* @var mixed[]
*/
private ?array $values = NULL;
private array $values = [];
/**
* @param array<string, array<string, mixed>> $definitions
@ -96,7 +96,7 @@ final class InputConfigurator {
* The collected input values, keyed by name.
*/
public function getValues(): array {
return $this->values ?? [];
return $this->values;
}
/**
@ -131,13 +131,15 @@ final class InputConfigurator {
* @throws \Symfony\Component\Validator\Exception\ValidationFailedException
* Thrown if any of the collected values violate their validation
* constraints.
* @throws \LogicException
* Thrown if input values have already been collected for this recipe.
*/
public function collectAll(InputCollectorInterface $collector, array &$processed = []): void {
// Don't bother collecting values for a recipe we've already seen.
if (in_array($this->prefix, $processed, TRUE)) {
return;
}
if (is_array($this->values)) {
if ($this->values) {
throw new \LogicException('Input values cannot be changed once they have been set.');
}
// First, collect values for the recipe's dependencies.
@ -146,7 +148,6 @@ final class InputConfigurator {
$dependency->input->collectAll($collector, $processed);
}
$this->values = [];
foreach ($this->data as $key => $data) {
$definition = $data->getDataDefinition();

View File

@ -39,6 +39,7 @@ class RecipeFormInputTest extends BrowserTestBase {
// All recipe inputs are required, except for checkboxes, for which that
// behavior makes no sense.
$this->submitForm(['input_test[owner]' => ''], 'Apply recipe');
$assert_session->statusCodeEquals(200);
$assert_session->statusMessageContains("Site owner's name field is required.", 'error');
$assert_session->statusMessageNotContains('Allow mischief field is required.', 'error');
// All inputs should be validated with their own constraints.

View File

@ -1,4 +1,8 @@
name: Input Test
recipes:
# Depend on another recipe in order to prove that we can collect input
# from recipes that depend on other recipes.
- no_extensions
input:
owner:
data_type: string