Problem/Motivation

When you delete a view display (and save the view), the dependencies added by that display are not removed from the dependencies list at the configuration entity for that view. It causes a remaining dependency relationship that shouldn't exist anymore. So, if you try to remove the related configuration, the entire view will be removed together.

The problem is softened by the fact that if you make any other changes to the view, the dependencies list is correctly updated. But if you just delete the display and save the view, the problem will be there.

Steps to reproduce

In a fresh standard install, I did:

1. Create a custom field (field_example) on the Article content type.

2. Create a view (id: example) for articles with a page display listing titles.

3. Create a block display and add (only for that display) the field_example on fields section; save view after that.

4. Run drush cex, so I can see the field_example listed as dependency on views.view.example.yml.

dependencies:
  config:
    - field.storage.node.field_example
  module:
    - node
    - user

5. Open view for editing again; delete the block display and save.

6. Run drush cex again. The view's configuration file is updated.

If you inspect the views.view.example.yml in that moment, the block display is gone, but the field_example continues listed on dependencies.config section. There is no other reference to the field except that.

Furthermore, if you try to delete field_example, the view is listed to be deleted together.

I also tested with a custom user role. I put it as an access requirement on a display and deleted the display after that. The same happened: the role continued listed as view's dependency.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

gedvan created an issue. See original summary.

quietone’s picture

Issue tags: +Bug Smash Initiative

I tested this on 9.3.x and was able to reproduce this error. I followed the steps given in the Issue Summary.

I searched in views.module component for duplicates and didn't find one.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.1.10 (June 4, 2021) and Drupal 9.2.10 (November 24, 2021) were the last bugfix releases of those minor version series. Drupal 9 bug reports should be targeted for the 9.3.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

amateescu’s picture

Just closed a bug in the Entityqueue module where people have bumped into the same problem described here. #3170718: Entityqueue doesn't remove dependencies from Views when no longer associated

j_s’s picture

Same issue occurring with the plugin provided by views_ical module. #3445191: Uninstall wants to delete whole view

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.