If I add an attachment to a display in a view and then change the display's machine name Views breaks all over the place.

You can't:

  • get to the Views overview page.
  • save the view.
  • delete the view.
  • cancel the changes to the view.
  • change the machine name back.
  • relink the attachment to the new display machine name.

I have linked a parent issue which I think is the same thing:

https://www.drupal.org/project/drupal/issues/3035949

--

In my case I found that editing the following allowed me to select a new machine name for the attachment however this probably needs looking at in more depth.

core/modules/views/src/Plugin/views/display/Attachment.php - Line 193

Change:

if ($this->view->displayHandlers->has($display_id) && $this->view->displayHandlers->get($display_id)->acceptAttachments()) {

To:

if ($this->view->displayHandlers->has($display_id) && $this->view->displayHandlers->get($display_id) && $this->view->displayHandlers->get($display_id)->acceptAttachments()) {

Proposed resolution

Update the machine name in all the attachments attached to the display.

Issue fork drupal-3091003

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

RaphaelBriskie created an issue. See original summary.

RaphaelBriskie’s picture

Issue summary: View changes

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.9 was released on November 6 and is the final full bugfix release for the Drupal 8.7.x series. Drupal 8.7.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.8.0 on December 4, 2019. (Drupal 8.8.0-beta1 is available for testing.)

Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

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

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

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.

borisson_’s picture

Issue tags: +Bug Smash Initiative

Is the sensible solution here to disable changing the machine name of the view in this case instead?

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.

feyp’s picture

Is the sensible solution here to disable changing the machine name of the view in this case instead?

If possible, I think it would be better to update the display id of the attachments to the new display id during save.

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.

sukr_s made their first commit to this issue’s fork.

sukr_s’s picture

Issue summary: View changes
Status: Active » Needs review

smustgrave made their first commit to this issue’s fork.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Ran test-only feature here https://git.drupalcode.org/issue/drupal-3091003/-/jobs/1475951 which shows the coverage

Applied a nitpicky change for the test.

Wish there was a hasAttached function call vs calling getAttachedDisplays() every time but definitely not in scope here. Changes does address the issue.

  • longwave committed 72e1a979 on 10.2.x
    Issue #3091003 by sukr_s, smustgrave, RaphaelBriskie, FeyP, borisson_:...

  • longwave committed 8367edf3 on 10.3.x
    Issue #3091003 by sukr_s, smustgrave, RaphaelBriskie, FeyP, borisson_:...

  • longwave committed d45f21b7 on 10.4.x
    Issue #3091003 by sukr_s, smustgrave, RaphaelBriskie, FeyP, borisson_:...

  • longwave committed 8a7586f8 on 11.0.x
    Issue #3091003 by sukr_s, smustgrave, RaphaelBriskie, FeyP, borisson_:...

  • longwave committed 26e5ef20 on 11.x
    Issue #3091003 by sukr_s, smustgrave, RaphaelBriskie, FeyP, borisson_:...
longwave’s picture

Version: 11.x-dev » 10.2.x-dev
Status: Reviewed & tested by the community » Fixed

A nice straightforward fix and test. I did wonder what else breaks if you change a machine name - should we have another layer of indirection such as UUIDs that never change? - but this will solve the immediate problem.

Backported to 10.2.x as an eligible bug fix.

Committed and pushed 26e5ef207a to 11.x and 8a7586f81e to 11.0.x and d45f21b776 to 10.4.x and 8367edf312 to 10.3.x and 72e1a9792b to 10.2.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.