Skip to content
Snippets Groups Projects
Verified Commit 328648c5 authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3365239 by ksere, bcgreen, lauriii, joey-santiago, Chris Matthews,...

Issue #3365239 by ksere, bcgreen, lauriii, joey-santiago, Chris Matthews, kevinquillen, michaellenahan, onfire84, Mysdiir: Status message confirming field deletion incorrectly references 'content type'
parent b07fdfae
No related branches found
No related tags found
40 merge requests!8528Issue #3456871 by Tim Bozeman: Support NULL services,!8323Fix source code editing and in place front page site studio editing.,!6278Issue #3187770 by godotislate, smustgrave, catch, quietone: Views Rendered...,!54479.5.x SF update,!3878Removed unused condition head title for views,!38582585169-10.1.x,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3668Resolve #3347842 "Deprecate the trusted",!3651Issue #3347736: Create new SDC component for Olivero (header-search),!3546refactored dialog.pcss file,!3531Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!3502Issue #3335308: Confusing behavior with FormState::setFormState and FormState::setMethod,!3452Issue #3332701: Refactor Claro's tablesort-indicator stylesheet,!3451Issue #2410579: Allows setting the current language programmatically.,!3355Issue #3209129: Scrolling problems when adding a block via layout builder,!3226Issue #2987537: Custom menu link entity type should not declare "bundle" entity key,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3147Issue #3328457: Replace most substr($a, $i) where $i is negative with str_ends_with(),!3146Issue #3328456: Replace substr($a, 0, $i) with str_starts_with(),!3133core/modules/system/css/components/hidden.module.css,!31312878513-10.1.x,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2614Issue #2981326: Replace non-test usages of \Drupal::logger() with IoC injection,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2334Issue #3228209: Add hasRole() method to AccountInterface,!2062Issue #3246454: Add weekly granularity to views date sort,!1255Issue #3238922: Refactor (if feasible) uses of the jQuery serialize function to use vanillaJS,!1105Issue #3025039: New non translatable field on translatable content throws error,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!844Resolve #3036010 "Updaters",!673Issue #3214208: FinishResponseSubscriber could create duplicate headers,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #38115 canceled
Pipeline: drupal

#38126

    Pipeline: drupal

    #38125

      Pipeline: drupal

      #38124

        +1
        ......@@ -477,7 +477,7 @@ public function testCommentFunctionality() {
        $this->drupalGet('comment/reply/entity_test/' . $this->entity->id() . '/comment');
        $this->assertSession()->fieldValueEquals('comment_body[0][value]', '');
        $this->fieldUIDeleteField('admin/structure/comment/manage/comment', 'comment.comment.comment_body', 'Comment', 'Comment settings');
        $this->fieldUIDeleteField('admin/structure/comment/manage/comment', 'comment.comment.comment_body', 'Comment', 'Comment settings', 'comment type');
        $this->drupalGet('comment/reply/entity_test/' . $this->entity->id() . '/comment');
        $this->assertSession()->fieldNotExists('comment_body[0][value]');
        // Set subject field to autogenerate it.
        ......
        ......@@ -5,6 +5,7 @@
        use Drupal\Core\Config\Entity\ConfigEntityInterface;
        use Drupal\Core\Entity\EntityDeleteForm;
        use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
        use Drupal\Core\Entity\EntityTypeManagerInterface;
        use Drupal\Core\Form\FormStateInterface;
        use Drupal\Core\Render\Element;
        use Drupal\field_ui\FieldUI;
        ......@@ -29,9 +30,16 @@ class FieldConfigDeleteForm extends EntityDeleteForm {
        *
        * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info
        * The entity type bundle info service.
        * @param \Drupal\Core\Entity\EntityTypeManagerInterface|null $entity_type_manager
        * The entity type manager service.
        */
        public function __construct(EntityTypeBundleInfoInterface $entity_type_bundle_info) {
        public function __construct(EntityTypeBundleInfoInterface $entity_type_bundle_info, ?EntityTypeManagerInterface $entity_type_manager = NULL) {
        $this->entityTypeBundleInfo = $entity_type_bundle_info;
        if (!$entity_type_manager) {
        @trigger_error('Calling ' . __METHOD__ . '() without the $entity_type_manager argument is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. See https://www.drupal.org/node/3396525', E_USER_DEPRECATED);
        $entity_type_manager = \Drupal::service('entity_type.manager');
        }
        $this->entityTypeManager = $entity_type_manager;
        }
        /**
        ......@@ -39,7 +47,8 @@ public function __construct(EntityTypeBundleInfoInterface $entity_type_bundle_in
        */
        public static function create(ContainerInterface $container) {
        return new static(
        $container->get('entity_type.bundle.info')
        $container->get('entity_type.bundle.info'),
        $container->get('entity_type.manager'),
        );
        }
        ......@@ -93,25 +102,44 @@ public function getCancelUrl() {
        */
        public function submitForm(array &$form, FormStateInterface $form_state) {
        $field_storage = $this->entity->getFieldStorageDefinition();
        $bundles = $this->entityTypeBundleInfo->getBundleInfo($this->entity->getTargetEntityTypeId());
        $bundle_label = $bundles[$this->entity->getTargetBundle()]['label'];
        $target_entity_type_id = $this->entity->getTargetEntityTypeId();
        $target_bundle = $this->entity->getTargetBundle();
        $target_entity_definition = $this->entityTypeManager->getDefinition($target_entity_type_id);
        $target_entity_bundle_entity_type_id = $target_entity_definition->getBundleEntityType();
        if (empty($target_entity_bundle_entity_type_id)) {
        $source_label = $this->t('entity type');
        }
        else {
        $target_entity_bundle_entity_type_definition = $this->entityTypeManager->getDefinition($target_entity_bundle_entity_type_id);
        $source_label = strtolower($target_entity_bundle_entity_type_definition->getLabel());
        }
        $bundles = $this->entityTypeBundleInfo->getBundleInfo($target_entity_type_id);
        $bundle_label = $bundles[$target_bundle]['label'];
        if ($field_storage && !$field_storage->isLocked()) {
        $this->entity->delete();
        $this->messenger()->addStatus($this->t('The field %field has been deleted from the %type content type.', ['%field' => $this->entity->label(), '%type' => $bundle_label]));
        $this->messenger()->addStatus($this->t('The field %field has been deleted from the %type %source_label.', [
        '%field' => $this->entity->label(),
        '%type' => $bundle_label,
        '%source_label' => $source_label,
        ]));
        }
        else {
        $this->messenger()->addError($this->t('There was a problem removing the %field from the %type content type.', ['%field' => $this->entity->label(), '%type' => $bundle_label]));
        $this->messenger()->addError($this->t('There was a problem removing the %field from the %type %source_label.', [
        '%field' => $this->entity->label(),
        '%type' => $bundle_label,
        '%source_label' => $source_label,
        ]));
        }
        $form_state->setRedirectUrl($this->getCancelUrl());
        // Fields are purged on cron. However field module prevents disabling modules
        // when field types they provided are used in a field until it is fully
        // purged. In the case that a field has minimal or no content, a single call
        // to field_purge_batch() will remove it from the system. Call this with a
        // low batch limit to avoid administrators having to wait for cron runs when
        // removing fields that meet this criteria.
        // Fields are purged on cron. However field module prevents disabling
        // modules when field types they provided are used in a field until it is
        // fully purged. In the case that a field has minimal or no content, a
        // single call to field_purge_batch() will remove it from the system. Call
        // this with a low batch limit to avoid administrators having to wait for
        // cron runs when removing fields that meet this criteria.
        field_purge_batch(10);
        }
        ......
        ......@@ -113,7 +113,7 @@ public function testDeleteField() {
        $this->assertSession()->pageTextNotContains('test_view_field_delete');
        // Delete the first field.
        $this->fieldUIDeleteField($bundle_path1, "node.$type_name1.$field_name", $field_label, $type_name1);
        $this->fieldUIDeleteField($bundle_path1, "node.$type_name1.$field_name", $field_label, $type_name1, 'content type');
        // Check that the field was deleted.
        $this->assertNull(FieldConfig::loadByName('node', $type_name1, $field_name), 'Field was deleted.');
        ......@@ -129,7 +129,7 @@ public function testDeleteField() {
        $this->assertSession()->elementNotExists('css', '#edit-entity-deletes');
        // Delete the second field.
        $this->fieldUIDeleteField($bundle_path2, "node.$type_name2.$field_name", $field_label, $type_name2);
        $this->fieldUIDeleteField($bundle_path2, "node.$type_name2.$field_name", $field_label, $type_name2, 'content type');
        // Check that the field was deleted.
        $this->assertNull(FieldConfig::loadByName('node', $type_name2, $field_name), 'Field was deleted.');
        ......
        ......@@ -275,7 +275,7 @@ public function testDeleteTaxonomyField() {
        $this->fieldUIAddNewField($bundle_path, $this->fieldNameInput, $this->fieldLabel);
        // Delete the field.
        $this->fieldUIDeleteField($bundle_path, "taxonomy_term.tags.$this->fieldName", $this->fieldLabel, 'Tags');
        $this->fieldUIDeleteField($bundle_path, "taxonomy_term.tags.$this->fieldName", $this->fieldLabel, 'Tags', 'taxonomy vocabulary');
        // Check that the field was deleted.
        $this->assertNull(FieldConfig::loadByName('taxonomy_term', 'tags', $this->fieldName), 'Field was deleted.');
        ......
        ......@@ -165,8 +165,10 @@ public function fieldUIAddExistingField($bundle_path, $existing_storage_name, $l
        * The label of the field.
        * @param string $bundle_label
        * The label of the bundle.
        * @param string $source_label
        * (optional) The label of the source entity type bundle.
        */
        public function fieldUIDeleteField($bundle_path, $field_name, $label, $bundle_label) {
        public function fieldUIDeleteField($bundle_path, $field_name, $label, $bundle_label, string $source_label = '') {
        // Display confirmation form.
        $this->drupalGet("$bundle_path/fields/$field_name/delete");
        $this->assertSession()->pageTextContains("Are you sure you want to delete the field $label");
        ......@@ -176,7 +178,7 @@ public function fieldUIDeleteField($bundle_path, $field_name, $label, $bundle_la
        // Submit confirmation form.
        $this->submitForm([], 'Delete');
        $this->assertSession()->pageTextContains("The field $label has been deleted from the $bundle_label content type.");
        $this->assertSession()->pageTextContains("The field $label has been deleted from the $bundle_label $source_label");
        // Check that the field does not appear in the overview form.
        $xpath = $this->assertSession()->buildXPathQuery('//table[@id="field-overview"]//span[@class="label-field" and text()= :label]', [
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Finish editing this message first!
        Please register or to comment