Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Issue:
Changing machine name, duplicating a Page to a Block silently removes the Page.
Steps to reproduce:
1) Create a Page on any view or create new one;
2) Select "Machine name" and "Apply";
3) Select "Duplicate as Block";
You can see that the Block has the same machine name now;
4) Save.
Expected: 1 Page and 1 Block.
Result: 1 Block only.
No notifications about deleting the page or having two identical machine names are displayed.
I have not tested on 8.5 versions, but I assume nothing has changed about this.
Comment | File | Size | Author |
---|---|---|---|
#15 | 2915175-15.patch | 2.03 KB | Anonymous (not verified) |
Comments
Comment #2
Phonoman CreditAttribution: Phonoman commentedComment #3
Phonoman CreditAttribution: Phonoman commentedComment #4
swentel CreditAttribution: swentel as a volunteer commentedSounds a bit like #2897576: Resaving a view display results in deletion of view display - although not entirely the same
Comment #5
Phonoman CreditAttribution: Phonoman commentedChanging to views_ui.module since the issue happens when working with UI.
Comment #6
Phonoman CreditAttribution: Phonoman commentedThis still currently occurs.
Comment #7
Anonymous (not verified) CreditAttribution: Anonymous commented@Phonoman, good catch and steps to reproduce!
I added a patch that fixes the duplication problem (just unset new_id key).
But looks like we need more attention to this problem. Example, if we change two display id on same new id, we also have this problem:
.
I tried to fix this problem on the UI level, but maybe we need to do it on more lower level. But I do not know exactly where:
views/View::set
,views/View::preSave
,view_ui/ViewEditForm
, ...?Review of change on the UI level:
Here, only one more check
$display->display['new_id']
is added, by analogy with check$display->new_id
, but the condition was very long, so it is divided into severalif
and lines, for better readability.Comment #8
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #9
Anonymous (not verified) CreditAttribution: Anonymous commentedThis is true.
Comment #13
Anonymous (not verified) CreditAttribution: Anonymous commented#7:
Even if we need control at this lower level, then perhaps we can do it in a separate issue?
Currently, patch #7 fixes the problem at the UI level. Since the steps described in IS lead to the loss of all the data from the display (and the display, of course), it is possible to change status on Critical?
Comment #14
LendudeNice find, nice tests, but I agree with @vaplas: not too sure about the fix.
Also, we seem to be fixing 2 bugs in one issue at the moment. If we can get one fix that fixes both cases I'm fine with doing it in one issue, but currently it's two fixes for two problems in one issue.
I think this should be a fix by itself. I think that is RTBC with just a nit fixed for the comment. And even if we come up with a generic way of preventing duplicate display names, just cleaning up the data when cloning makes sense anyway.
The other fix:
This seems very fragile. And I agree with @vaplas that it would be better to fix that whole logic at a different level then the UI. Some way we can just say 'We never allow duplicate display machine names when saving a view'. @vaplas suggestion of
views/View::preSave
sounds like a good place to start.nitpicking some comments:
Test duplicating a display after changing the machine name.
Test setting the same machine name for two different displays before saving.
Comment #15
Anonymous (not verified) CreditAttribution: Anonymous commented@Lendude, thanks for review and a wise remark about two problems in one issue. Now I see that this is true! Open separated issue by #14: #2944859: Never allow duplicate display machine names when saving a view (clean up IS too).
Here is the first half of the patch #7 + #14.1 comment fix:
Comment #16
Lendude@vaplas thanks for that! This looks good.
Bumping this to critical since it leads to data loss through normal use of the UI.
Since it's not a common scenario, it might just be major, but it's not like it takes a weird setup to get into this state.
Comment #18
catchCommitted/pushed to 8.6.x and cherry-picked to 8.5.x. Thanks!