From fc8ececeeb92b427fcde45671ab2d721988869c6 Mon Sep 17 00:00:00 2001 From: Dieter Holvoet Date: Sun, 12 Dec 2021 20:43:13 +0100 Subject: [PATCH] Validate whether field-name option is a valid field --- src/Drupal/Commands/core/FieldDeleteCommands.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Drupal/Commands/core/FieldDeleteCommands.php b/src/Drupal/Commands/core/FieldDeleteCommands.php index d818acb8a4..2eb89cb681 100644 --- a/src/Drupal/Commands/core/FieldDeleteCommands.php +++ b/src/Drupal/Commands/core/FieldDeleteCommands.php @@ -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