Verified Commit 7d7980a8 authored by godotislate's avatar godotislate
Browse files

fix: #3572679 Prevent undefined array key warnings in AddToAllBundles

By: liam morland
By: phenaproxima
By: neptune-dc
(cherry picked from commit b7fce18f)
parent a9885aa9
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -76,9 +76,9 @@ public function apply(string $configName, mixed $value): void {
        throw new ConfigActionException(sprintf('Field %s already exists.', $id));
      }
      $storage->create([
        'label' => $value['label'],
        'label' => $value['label'] ?? throw new ConfigActionException(sprintf('The `label` property must be set for %s.', $id)),
        'bundle' => $bundle,
        'description' => $value['description'],
        'description' => $value['description'] ?? '',
        'field_storage' => $field_storage,
      ])->save();
    }
+22 −0
Original line number Diff line number Diff line
@@ -149,6 +149,28 @@ public function testIgnoreExistingFields(): void {
    $this->assertSame('Set by config actions.', $field->getDescription());
  }

  /**
   * Tests that the action fails when the label property is not set.
   */
  public function testMissingLabel(): void {
    $contents = <<<YAML
name: Instantiate field on all bundles
config:
  import:
    entity_test_with_storage:
      - field.storage.entity_test.body
  actions:
    field.storage.entity_test.body:
      addToAllBundles:
        description: Set by config actions.
YAML;
    $recipe = $this->createRecipe($contents);

    $this->expectException(ConfigActionException::class);
    $this->expectExceptionMessage('The `label` property must be set for entity_test.entity_test.body.');
    RecipeRunner::processRecipe($recipe);
  }

  /**
   * Applies a recipe with the addToAllBundles action.
   *