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
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
Comment #2
RaphaelBriskie commentedComment #8
borisson_Is the sensible solution here to disable changing the machine name of the view in this case instead?
Comment #10
feyp commentedIf possible, I think it would be better to update the display id of the attachments to the new display id during save.
Comment #14
sukr_s commentedComment #16
smustgrave commentedRan 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.
Comment #22
longwaveA 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!