Skip to content

Commit

Permalink
Validate whether field-name option is a valid field
Browse files Browse the repository at this point in the history
  • Loading branch information
DieterHolvoet committed Dec 15, 2021
1 parent 12e7564 commit 09f0ffc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Drupal/Commands/core/FieldDeleteCommands.php
Expand Up @@ -81,6 +81,15 @@ public function delete(string $entityType, ?string $bundle = null, array $option
'bundle' => $bundle,
]);

if ($results === []) {
throw new \InvalidArgumentException(
t("Field with name ':fieldName' does not exist on bundle ':bundle'.", [
':fieldName' => $fieldName,
':bundle' => $bundle,
])
);
}

$this->deleteFieldConfig(reset($results));

// Fields are purged on cron. However field module prevents disabling modules
Expand Down

0 comments on commit 09f0ffc

Please sign in to comment.