Problem/Motivation
When deleting a content type field, the UI shows the view as a dependency under configuration deletions and deletes the view when you confirm the delete.
In D7, the view gets automatically updated. (sort of, see #15). Users apparently do not expect this behavior and end up accidentally deleting a whole view. Possible user experience problems with this:
- The delete section is at the bottom of what is potentially a long list of updated configuration.
- Users get used to just confirming the less severe configuration entity updates and so are not aware they are deleting a whole view.
- Even if the user sees the message about deletion, there is no information on how to fix it instead.
Proposed resolution
The behavior itself should not be changed, but we can improve the user experience problem:
- Make deletions more obvious than automated dependency removals, possibly with a confirm form.
- Provide stronger/clearer warnings in the UI, e.g."Warning: You are about to delete an entire view".
- Provide instructions on what to do instead,e.g. "To remove this field without deleting these items, first edit the items so they no longer use this field."
Alternate resolution from #51 and onward:
The behaviour should be changed. By default, the View should just be disabled. An attempt can be made to update it by removing handlers that trigger the dependency, if this still leaves dependencies, disable the View so the user can manually update the View before enabling it again. This will prevent any unexpected data loss.
Things to look at (possibly in follow-ups):
Make sure the View gets deleted when the module providing the base table is uninstalled(fixed in #83)- Add a check that a View is valid when enabling it.
- Add a fieldset to the confrm screen with all disabled config instead of putting it under 'updated' (follow up: #2832558: Add a 'disabled' section to config changes page when removing config)
Alternate resolution from #91 and onward:
The behaviour should be changed but only for field handlers. The proposed solution would be to remove any field handlers that have a dependency on any configuration being removed. If that solves all the dependencies then the View can just be updated and saved without this field. Dependencies because of other handlers (filters, relationships et al.) will still cause the whole View to be deleted. The removal of a field handler should have little impact on the overall working of the View, so the normal notice that it will be updated should suffice for that.
The deletion of a View because of a field handler is probably the most commonly occurring situation and the one where removing the handler should not have any dramatic effects.
Follow ups will be opened to see how we can handle the other types of handlers on a handler-type basis.
Remaining tasks
Decide on a proposed resolution. Needs designs and usability review for them once proposed.
User interface changes
TBD
Original report by [username]
I created a 'date' field on a content type and a view to for this content type.
Then i deleted the 'date' field from the content type and the whole view got deleted also without any warnings.
Comment | File | Size | Author |
---|---|---|---|
#154 | do_not_jump.png | 147.13 KB | Anonymous (not verified) |
#141 | 2468045-141.patch | 13.02 KB | Lendude |
#141 | interdiff-2468045-140-141.txt | 943 bytes | Lendude |
#140 | interdiff-138-140.txt | 833 bytes | Anonymous (not verified) |
#140 | 2468045-140.patch | 12.29 KB | Anonymous (not verified) |
Comments
Comment #1
dawehnerOH, yeah it should ideally just remove the corresponding field from the view.
Btw. I disagree that this should be done in 8.1.x but instead fixed in 8.0.x directly. It also sounds at least major for me.
Comment #2
BerdirDo fields not have a delete confirmation form? That should list what will be removed/updated.
Yes, this something that can be fixed in 8.0.x, I think the assigment was just done incorrectly. Sounds like a non-trivial thing to implement, though. A dependency could be *anywhere*, in a field, argument, filter, it could be a menu the view is displayed in.. every plugin could be responsible.. so we would kind of need to go through all them, find those that depend on it and somehow automatically drop them?
Comment #3
swirtToo add some more details here. I did some testting. Deleting a date does indeed delete the view IF the view is a view of fields. It does not delete the view if it is a view of content teasers. Also confirmed this is not specific to just date fields.
Comment #4
no_angel CreditAttribution: no_angel commentedI can also verify that when the date field is deleted, the view is also deleted but the view of teaser is not deleted.
Comment #5
swirtAdditional info: If the same field is used as an existing field on another content type, deleting the field from either content type does not result in the view being removed. So this is only happening when the field data is completely removed. Still digging for what service or hook is deleting the view instead of updating it.
Comment #6
BerdirThe process starts in ConfigEntityBase::preDelete(), there it's looking for configuration that depends on the entity that is being deleted and deletes those things, unless they implement the methods to update themself.
See EntityDisplayBase::onDependencyRemoval() on how the view/form display configuration updates itself when a field is deleted. Views will have to implement something like that.
Comment #7
swirtThat helps a lot Berdir. Thank you for pointing me in the right direction. We had 5 well established engineers looking at this issue on a codesprint at a drupal camp yesterday and we came up empty. This helps.
Comment #8
geertvd CreditAttribution: geertvd at XIO commentedThis is still a work in progress but already prevents forms from being deleted and just removes the field on the view instead.
We still have to make sure the same happens for filters and sorts (and maybe some other stuff I'm forgetting) I assume.
If somebody could already have look at this to see if this is going in the right direction that would be great.
Comment #9
swirtThanks geertvd I will review this later today.
Comment #10
geertvd CreditAttribution: geertvd at XIO commentedJust checked this for filters, sorts and contextual filters. The view doesn't get removed for those but the "Broken/missing handler" label appears.
Ideally
onDependencyRemoval()
should be triggered for those also though.Having a look now to find out why these are not dependencies to the field.
Comment #11
geertvd CreditAttribution: geertvd at XIO commentedThese dependencies should have been fixed in #2372855: Add content & config entity dependencies to views is there any reason why it wasn't added there?
IS states that "fields used in filters" should also be dependent but at the moment that's not the case.
If I were to make them dependent I'n not sure where's the best place to implement
calculateDependencies()
Comment #12
geertvd CreditAttribution: geertvd at XIO commentedThis should handle removal of all dependent handlers (including sorts, filters, etc.)
Still working on making filters and other handler types dependent since this is just the case for fields right now.
Comment #13
geertvd CreditAttribution: geertvd at XIO commentedKinda stuck here.
The following plugins are still missing config dependency:
Since these plugins don't have a baseclass that is used for entity fields, I don't think we can use
calculateDependencies()
here.I discussed this briefly with dawehner at drupaldevdays, he helped me in the right direction to write the
onDependencyRemoval()
method more generically for all handler types.We were thinking about doing something simular to calculate the dependencies for handler types also if I remember correctly but I can't figure out where is the best place to do that.
Comment #14
Jaesin CreditAttribution: Jaesin at Chapter Three commentedMost views plugins would depend on the field storage and that doesn't get removed until the the last instance of that field is removed (obviously).
I would argue that modules should be hard dependencies for views but fields should be soft dependencies (Is there such a thing?) since there are broken handler fallbacks.
It would be great if we showed a view has broken dependencies in the view list but I disagree with trying to remove the missing components. You want to see the broken handlers so you can fix them which probably means replacing one field with another if you are refactoring a content type.
Comment #15
geertvd CreditAttribution: geertvd at XIO commentedThanks for reviving this issue.
How this is working in d7 now (for fields):
Let's go over how it currently works in d8:
Now when I apply patch #12 steps 1 and 2 remain the same, but when I go back to my view, it's still there and my field has been cleaned up from the field handlers.
I wouldn't call showing a broken/missing handler a soft dependency, I think we should really only have the broken handlers when something has been changed/removed programmatically. If we can avoid using them we should.
I don't know if that's an assumption we can make, this just adds more steps for the site builder.
Comment #16
Jaesin CreditAttribution: Jaesin at Chapter Three commentedI took a poll around the office and got very mixed opinions about removing the views component when a field is removed.
What about contextual filter?. If you remove a contextual filter you could possibly expose data that wasn't indented to be exposed such as student contact information on a view page that is intended to only have staff contact information exposed.
Another consideration is if rewrite is being used in a field to include other hidden fields.
I guess the point of these two is that there is more configuration in a views plugin than just the field and if you remove a field, filter, sort or contextual filter you are removing the rest of the configuration for that plugin as well.
Lastly, have we considered blocking the field removal because of views dependencies instead of removing the field from the view.
Comment #17
geertvd CreditAttribution: geertvd at XIO commented:) Awesome, I'll do the same at my office.
Fair point, but I don't think we can store every possible setting of every possible handler in the missing/broken handler (not sure)
For me this would be a very disturbing thing to do.
Comment #18
BerdirWe discussed this issue, and the agreement is that the critical part about this issue is the fact that you are not told that the view will be deleted.
For this, I've just promoted #2442757: Move the field storage deletion if the last field has been removed to the UI layer to critical. Then you can at least manually fix your view before it gets deleted and you know about it. This is something that we can also fix after 8.0.0 if we don't get to it before.
Comment #19
Jaesin CreditAttribution: Jaesin at Chapter Three commentedI created #2575547: Formalize patterns for delete/uninstall of configuration dependencies as well that references this issue.
The concept in that issue is that there should also be soft dependencies which give warnings but are not strictly enforced. Modules must provide a fall-back if a dependency it declares as soft does not exist.
Comment #20
jhedstromWorking on a test.
Comment #21
jhedstromWeird, I manually reproduced this issue a few weeks ago, but now cannot reproduce it.
Comment #22
Berdir#2575605: Field delete form does not display configuration dependencies that will be updated/deleted added a test that makes sure the view is at least shown as being deleted, you can probably steal some code from there :)
Comment #23
no_angel CreditAttribution: no_angel commentedComment #24
xjmSo to clarify, now that #2575605: Field delete form does not display configuration dependencies that will be updated/deleted is resolved, this issue is about allowing the field configuration to be removed from the view without deleting the view?
I've mixed feelings about this because I think it's complicated and also depends on how the field is used in the view. If the field is used for a field plugin, then it makes sense to simply remove the data the same as it is removed from the content type itself. However, if the field is used as a filter for the view, then this could result in the view disclosing more information than it did previously.
Comment #25
xjmThe other option is to disallow removing the field until it is removed from the view, which would be more in line with the config dependency expectations I think.
Comment #26
xjmComment #27
tim.plunkettI agree with #25.
Comment #28
rakesh.gectcrComment #29
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #30
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #31
lokapujyaComment #32
lokapujyaComment #33
xjm(Fixing the tag.)
Comment #34
lokapujyaThat's not dependencies problem; The problem here is that someone used a field as a filter. A user that with permission to delete fields should certainly be able to make the choice to delete fields from a view.
It's possible that there are irrelevant views (even disabled views) that could block someone from deleting a field.
Comment #35
mediapal CreditAttribution: mediapal commentedOMG I just screwed up all my views are gone without any warning when I deleted a field.
Thank so much for ruin my day.
Comment #37
caspervoogt CreditAttribution: caspervoogt at Plethora commentedI second #25 as well. How a field gets used within a view can vary greatly, and the view might have a zillion other fields, relationships, contextual filters and what not. Recreating the view could be a major pain. If the field is used in a view, then the field should not be deletable yet, and it should show which views are using this field, to let the user decide to remove it from those views, or perhaps changes their mind and keep the field after all.
I feel either this or "1.) Allowing the field configuration to be removed from the view without deleting the view." would be far preferable to simply deleting the view (even with a confirmation / warning).
Comment #38
OlafskiAs a site builder who doesn't want to rebuild complex views, I like #25 but I'm also fine with other approaches where the relevant view won't be simply deleted. In my opinion it's critical to inform the users as fast as possible more clearly, even if the technical and conceptual questions of this issue need more time. For the time being, a confirmation dialog while field deletion tells you for example:
Configuration deletions
The listed configuration will be deleted.
View
- Articles
"The listed configuration will be deleted" may be correct from a technical view, but in my opinion it's not a very fortunate choice. In my case it was misleading: Quite experienced with Views in D7 but not in D8, I was not expecting at all that a view containing about 10 other fields, two relations and a contextual filter could be deleted because of a single deleted field. So I must have read the information wrongly as something like "The field configuration in the following View will be deleted." My fault not to check the meaning, no doubt, but I wouldn't have read the message wrongly if it said "The following View will be deleted." Looking at the structure of the warning text, it's however difficult to change the wording to this effect. Any suggestions?
Comment #39
caspervoogt CreditAttribution: caspervoogt at Plethora commentedI concur with Olafski. The message needs to be really blunt and obvious.
Comment #40
dawehnerGiven how many issues are floating around for that, this really feels like a uber-major for me.
Comment #41
sonfdI think I just experienced the same underlying issue, but triggered it a different way. I uninstalled views_filter_autosubmit (https://www.drupal.org/node/2475595) and the view I had enabled auto-submission on was deleted. The module just adds a Views Exposed Form Plugin and the deleted view was configured to use it. View Filter Auto Submit doesn't have any uninstall function so I think the view was deleted for the same underlying reason(s) views are deleted if a field is deleted.
(Maybe this is its own issue?)
Comment #42
xjm@alexpott, @timplunkett, @dawehner, and I discussed this issue awhile back at DrupalCon New Orleans.
In a way, this issue is working as intended: the config dependency system necessarily cleans up dependencies when the user removes configuration. This is the solution we chose in #2575605: Field delete form does not display configuration dependencies that will be updated/deleted and #2442757: Move the field storage deletion if the last field has been removed to the UI layer. For important background on the overall problem space, see #2416409: Delete dependent config entities that don't implement onDependencyRemoval() when a config entity is deleted. (Also see e.g. #2212081: Remove views optional handler handling for how we changed Views in D8.)
It is not correct to "update" existing configuration automatically as we do with the entity displays. Say for example the field was being used to restrict access on the view. If we tried to "guess" the user's intentions and magically update the view, it could result in unintended information disclosure when suddenly all data was accessible. So, the correct way for the user to address the issue is to remove the field from the view first. That way, the user can reconfigure the view as appropriate.
The user is even informed on a confirmation form:
(I was unable to reproduce any way of not getting this confirmation message.)
However, it is clearly a major usability bug if users accidentally delete their configuration and lose the data. I think there are three problems here:
Therefore, we probably need to warn users more strongly before they delete configuration. One resolution we discussed is using a modal (similar to the modal that warns you before you click on a link in a preview and thus lose your user input). That message could also display short help text about editing the other thing first to remove the dependency as an alternative.
Comment #43
dawehnerThere are two major issues when a field is removed:
Does anyone has opinions about it? IMHO these two actions would solve most of the problems out there.
Comment #44
Olafski@dawehner, #43: Good idea to distinguish the two cases! I would be happy about this solution.
Said that, there will be other cases, e.g. a field used as sort criteria, but I guess even more, some of them not so obvious. Can we treat them all like case 1 (a field in a configured views field)?
Comment #45
xjmRelated issue for a similar destructive confirm form.
Comment #46
xjmWe now have #2773205: Come up with a design for highly destructive operations in confirm forms for an overall design for these highly destructive operations. This issue could start though by putting the Delete fieldset up top, improving the form text, etc., which would be independent of that interaction.
I'm not sure about #43. Who knows what custom behavior someone could have created for their view? I guess we could say the contrib/custom author is responsible for making the configuration system do the right thing in that case, but I doubt they will if we have struggled to with core. Maybe it's three separate issues: the one linked above, one for improving the config confirm form internally, and one for the dependency question for Views and their plugins.
Comment #47
dawehner#46
IMHO a broken site in that sense is still MUCH better than what we do at the moment. I cannot tell how many people asked me about this behaviour already and all of them lost significant work or at least significant time,
Comment #49
Jeff Cardwell CreditAttribution: Jeff Cardwell as a volunteer commentedIs simply disabling the view out of the question? Seems like it might be a bit of all worlds. It "breaks" the site, but does not "destroy" any configuration. Not sure how it falls into line with the rest of the UX stuff though.
Comment #50
jhedstromThere's already some logic baked in for automatically updating configurations that depend on a deleted configuration. For instance, deleting a field does not delete the corresponding
core.entity_view_display.*
configurations that specify a dependency on that field. That dependent configuration is updated to remove the dependency instead. I'm not exactly sure of the logic in charge of this, and don't know if it's generic enough to be used in the case of views.If that logic isn't generally reusable, I think simply leaving the view to use the broken handlers is acceptable, and we could potentially even create a report that highlights broken configurations?
Comment #51
aklump CreditAttribution: aklump at In the Loft Studios commentedI'd like to add that when I deleted a user role today, I also lost two views that used that role in the permissions. This was totally unexpected and a huge departure from what Drupal 7 "trained me" to expect.
Comment #52
dawehnerIs there actually an issue which discusses to take a snapshot of config when these kind of deletions happens?
Comment #53
cilefen CreditAttribution: cilefen commentedRe #51: If it isn't obvious deleting a content type does this also, although that is not as sympathetic as case as is a field deletion or a user role. This issue makes me sad because a view can be such a valued piece of configuration. I can understand the argument towards removing one because we cannot predict what the effect on a given view would be. But as a site builder, I would be furious at myself and everyone else by accidently deleting a view I hadn't backed up.
Comment #54
Anonymous (not verified) CreditAttribution: Anonymous commentedThe pain from this problem can not be measured. The administrator wants to improve the structure and the site transformed into a pumpkin. Nobody reads the warning. But all hate me for this effect (and I hate all back, of course). Even subconsciously I am trying to use only displays format for style (even when it is very inconvenient). IMHO, a Fatal Error when deleting field is a thousand times better than plain warning description.
Comment #55
typologist CreditAttribution: typologist as a volunteer commentedAARRGH, I JUST DELETED a View with 5 pages inside!! The current warning is not enough, even worse this being not the default behaviour in D7. Definitely a more prominent warning is needed :(
Comment #56
Anonymous (not verified) CreditAttribution: Anonymous commentedJust leave it here. Module disabling "Submit button" of delete form until all dependent views not corrected (+ edit link for each views). It works only for next form: 'field_config_delete_form', 'user_role_delete_form', 'taxonomy_vocabulary_confirm_delete'.
Duplicate module code, if anyone is interested:
Comment #57
sheldonkemper CreditAttribution: sheldonkemper as a volunteer commentedWhy is this discussion leaning towards notifying users the views is to be deleted?? Better to have a broken view than no view at all.
Comment #58
cilefen CreditAttribution: cilefen commented#51 and on are leaning the other way.
Comment #59
dawehnerHere is alternative approach:
Comment #60
alexpottSo make it a soft dependency? Seems like it might work. I'm not sure what dependencies the disabled view would be though. Because it can not depend on something that is not there.
Comment #61
dawehnerWell, we could return nothing for the dependencies for disabled views.
Comment #62
BerdirThat could break things like install order or optional config?
Comment #63
caspervoogt CreditAttribution: caspervoogt at Plethora commentedI would even say: don't delete existing views, and don't disable them. Let the view have big fat errors, but maybe still provide a warning that this view will need attention. That way a) the admin will know the view needs work and b) if the admin does not notice the warning, it's on them but then at least the view is not gone. This is more in line with D7 default behavior for Views IMHO.
Comment #64
dawehner@caspervoogt
Well, I wanted to make a new suggestion, because we circle around the do nothing at all idea, already, and this didn't lead to any pratical outcome.
Comment #65
tim.plunkett+1 for #59/51
Comment #66
OlafskiI like @dawehner's approach in #59. There were other reasonable approaches, but let's finally decide how to fix this huge problem. So, let's be pragmatic and take the #59 approach. And one appeal in case anybody has objections: please make clear if your objections are fundamental, tell us by which degree you disagree, and suggest another manageable approach.
Comment #67
sheldonkemper CreditAttribution: sheldonkemper as a volunteer commented+1 #59
Comment #68
rakesh.gectcrSo lets go with the approach @dawehner suggested #59
Comment #69
ABaier CreditAttribution: ABaier commentedI also experienced this right now … lost three views, which took me quite some time to setup.
Also +1 for #51/#59 because I would expect to have "only" some broken fields instead of a deleted view.
Comment #70
jonathanshaw#59 +1
Comment #71
Anonymous (not verified) CreditAttribution: Anonymous commentedStill there is a moment when the relationship is left in the default settings, although all of the display override fields and not use it.
Example:
Because dependence saved in default settings and need create display with default fields and reset Blazy. Now this may seem obvious, but can someone come in handy.
Comment #72
Anonymous (not verified) CreditAttribution: Anonymous commentedOr create issue about clearing default settings (fields, filter, style...) if all of the displays are overridden it?
Comment #73
Andrej Galuf CreditAttribution: Andrej Galuf commentedAgree with #59, deleting a configuration / view is a BIG no-no. Disable, sure. Big fat errors, sure. Losing an entire configured view because the user had for a moment not paid attention? Disaster for UX - even if there is a warning before deletion.
Comment #74
bbuchert CreditAttribution: bbuchert as a volunteer commented+1 #59! Just lost a lot of views...
Comment #75
dawehnerI'm working on that atm.
Comment #76
dawehnerHere is a start of that.
Comment #77
Anonymous (not verified) CreditAttribution: Anonymous commented@dawehner thank you very match. Amazing start!
My patch has 4 changes:
Comment #78
LendudeRan into this too, time to fix this, REALLY annoying.
Started with #76 as a basis and borrowed some ideas from #77.
I don't think we need to go into a whole new area of disabled stuff, we can always do that in a follow up. Logging the disabling of the View is in line with what already happens in
\Drupal\Core\Entity\EntityDisplayBase
, so lets go with that now.Manually tested this and works for removing fields.
This incorporates the idea in #61 to make disabled Views return no dependencies, updated it to make it return no handler based dependencies.
Only thing I'm not totally happy with is that uninstalling the taxonomy module doesn't remove all taxonomy based Views (it just disables them).
Putting on needs review to trigger the bot, but obviously still needs work
Comment #79
dawehnerComment #81
LendudeUpdated the issue summary to reflect the current direction of the fix and some points that @dawehner and I discussed on IRC.
Comment #82
LendudeFixed/modified the existing tests to fit the new way of doing things. Also added a test for removing a dependency that causes the view to be disabled.
Added some extra comments based on #79. Probably need a follow-up issue to add to the @todo, so will look into that.
Still need to look at 'delete (don't just disable) views when the base entity gets removed' part of this. Or should that be a follow up too?
Comment #83
LendudeAdded a follow up for better feedback #2832558: Add a 'disabled' section to config changes page when removing config and added that to the @todo in the patch.
Added the check for a removed base table for the View and a test for that.
Comment #84
LendudeUpdated the IS a bit.
Comment #85
dawehnerI think we should actively check the state of the view afterwards, aka. disabled, with field removed. The other test coverage in the patch just deals with roles but not with entity fields
Comment #86
LendudeAdded additional status check per #85.
As discussed on IRC with @dawehner, the View actually stays enabled if we can remove the field and this solves all the missing dependencies.
Comment #87
Anonymous (not verified) CreditAttribution: Anonymous commentedGreat ideas! All works looks very professional! Many thanks! We have issue about better feedback (#2832558: Add a 'disabled' section to config changes page when removing config), and it requires this patch. Let's will get rid of the irritating behavior!)
Comment #89
johnwebdev CreditAttribution: johnwebdev commentedBeen reading through the lines;
If we create the view using say default configuration in a module config/install, would that mean we would need to update or exported views file to have it include the module as dependency if we wanted it to deleted on uninstall?
If it's not deleted, an reinstall on the module will FAIL because the View is already in active configuration. Can someone confirm this behaviour?
Comment #90
Lendude@johndevman Couple of things:
Comment #91
alexpottI don't think this is a valid approach. If disabled views don't have their dependencies then we are in the same position as disabled modules.
Comment #92
dawehnerI guess for now its okay to actually delete those views in this particular case. We at least have been able to solve the particular big problem of removed fields, in which case we don't have to disable it already as part of the patch. Any further work could be IMHO moved into a follow up. @Lendude do you agree with that?
Comment #93
Lendude@dawehner yes that is what I was thinking too. This would still fix the most annoying problem and would allow us to expand in follow ups what we can remove without deleting the whole View. Maybe set up a meta and open child issues per handler type and see how we want to tackle each case.
Comment #94
dawehnerGood idea!
Comment #95
LendudeOk, so something like this then. Removed all the disabling stuff and updated the test to reflect the change.
Comment #96
dawehnerThank you @Lendude!
Comment #97
tim.plunkettI think this should be in Drupal\Core\Plugin, it is generic. And it will help with #1764380: Merge PluginSettingsInterface into ConfigurableInterface, since \Drupal\Core\Field\PluginSettingsInterface::onDependencyRemoval() doesn't have a replacement yet
Alternatively, please mark this @internal with an @todo to move it later, whichever is easier.
Nit, should be
$display = &$view...
Comment #98
Lendude@tim.plunkett++
Moved it to
Drupal\Core\Plugin
and fixed nits.Comment #99
tim.plunkettThanks!
Comment #101
tim.plunkettMissed a spot, I think it's safe to set back to RTBC.
Comment #102
almaudoh CreditAttribution: almaudoh commentedWeird English :)
Comment #103
jonathanshaw"the field currently being deleted" is better
Comment #104
catchJust removing fields from the View could leave it non-functiona for the sitel. For example if it has contextual (or any filters really) on the field being deleted.
What happened to the solution in the issue summary to disable the view and show a message if fields are removed? That would at least prompt admins to review the configuration after this has happened.
Also is this definitely going to work if there's a relationship or similar using the field that's removed here? i.e. does the relationship get removed, and do the fields that depend on that relationship also get removed? Don't see this case in the test coverage.
Comment #106
Lendude@catch sorry, the issue summary is again out of date for the current attempt at fixing this. I updated the IS to add the current direction.
Some more specific answers to your questions
@alexpotts comment in #91 happend to it. If you have a suggestion on how to get back to that, I'm all ears, 'cause I really like that route.
Updated the issue summary to add my plan from #93 to open a follow-up meta with issues for all the different handler types and how to tackle them. Since you are absolutely correct that just removing them sounds like a bad idea, and different types would probably require different approaches.
Comment #107
catch#91 is pointing out a different problem to #104.
If we don't remove dependencies, and disable the views, then we have data integrity issues, 100% agreed we should not end up in that situation.
I'm suggesting if we really want to remove the dependencies, then we should also disable the view. This will then force the admin to review the view that's been altered, and either fix it or not.
Comment #108
Lendude@catch Ah! Ok, thanks for the clarification.
So, if I understand everything correctly the workflow would then be as follows:
- On delete, check if any handlers want to remove themselves (first phase: only field handlers)
- Remove any handlers from the View that want to be removed
- If any modification was done, disable the View
- If any dependencies still remain, delete the View
Sounds good to me. And would give a good first step on which we can build for the other handler types.
Comment #110
LendudeOk so this is a patch using this steps in #108
Comment #112
LendudeForget #110, removed the wrong stuff, this should be green.
Comment #113
dawehnerI agree with the new logic. This results into maximum safety, while still making it possible to not totally break people's side.
core/modules/views/tests/src/Kernel/ViewsConfigDependenciesIntegrationTest.php:16
In an ideal world, this test would have a dedicated test handler which does stuff instead of relying on the roles filter / fieldable field. Still I don't think this should block the patch.
Comment #114
cilefen CreditAttribution: cilefen commentedI was going to complain, then saw #2832558: Add a 'disabled' section to config changes page when removing config. #112 is definitely a UX improvement on its own.
I am able to cause this warning:
...by deleting a content type field (the default Article content type image field).
Comment #115
cilefen CreditAttribution: cilefen commentedComment #116
dawehnerInteresting, is
config_key
, NULL in that case?Comment #117
cilefen CreditAttribution: cilefen commentedIt is an instance of FieldStorageConfig.
Comment #118
cilefen CreditAttribution: cilefen commentedComment #119
Lendude@cilefen yeah I can reproduce this (well sorta, I see the wrong data in xdebug anyway). Something else I saw while trying to reproduce is that the timing of the log message is still wrong. A log entry is made when you are shown the list of config that needs updating, not when you actually do the update (so if you cancel, it's still logged)
Comment #120
_dcre_ CreditAttribution: _dcre_ at zehnplus commentedComment #121
LendudeOk, new stab at this.
Since the timing of logging a message is wrong we can lose the logic that causes #118, since that was only for determining if a message needed to be send.
I don't really see a way of logging a message were the timing is so that it's only logged when the disabling is actually done (so it's not done when you cancel your config change). Since the logging was a pretty weak effort at giving some feedback anyway, I'd opt for just leaving it out and moving forward with #2832558: Add a 'disabled' section to config changes page when removing config so we actually have some decent feedback.
Comment #122
Anonymous (not verified) CreditAttribution: Anonymous commentedI'll miss about it :( but commit of the issue still bring a lot happiness!
Comment #123
LendudeReroll for #2776975: March 3, 2017: Convert core to array syntax coding standards for Drupal 8.3.x RC phase
Comment #124
dawehnerCan we at least log that the view was disabled at all? I think that would be a valueable information.
Comment #125
Lendude@dawehner as far as I can tell there is no way to get the timing right for logging a message. \Drupal\Core\Config\ConfigManager::getConfigEntitiesToChangeOnDependencyRemoval can get called with $dry_run TRUE or FALSE, but the onDependencyRemoval call doesn't get this context, so it has no idea if it's doing a dry run or not. So if we log a message, we might be logging it during a dry run, when the View never actually get disabled at all (like during building the confirmation form).
So the only options I see are: logging too often, or not at all. And 'too often' doesn't sound like an option really.
So if you have an idea about how we could do this, I'd be happy to implement it, but I think this will just need #2832558: Add a 'disabled' section to config changes page when removing config for better feedback then just the 'will be updated' one.
Comment #126
dawehnerWe can always work on the messages later but not deleting them is the important step.
Comment #128
catchCommitted/pushed to 8.4.x, thanks! Tricky one this and good to see it green.
This could probably go into 8.3.x, but will get feedback from another committer first.
Comment #129
catchSpoke to xjm and we agreed this is good for 8.3.x too, so cherry picked. Thanks!
Comment #131
catchSpoke to @alexpott as well. This is in the global namespace, but nothing uses it apart from Views. This leaves open the possibility that something implements it thinking it'll be handled, when it won't.
Suggested moving to Views namespace, if we eventually figure out something generic, we could deprecate the Views interface when it moves to core.
reverted from both branches but should be a quick change for someone.
Comment #132
Lendude@tim.plunkett requested it be put in the global namespace in #97 because he had a use for it, but here it is, back in the Views namespace.
Comment #133
tim.plunkett#131 is entirely fair.
Not part of the plugin_api group anymore.
Comment #134
Anonymous (not verified) CreditAttribution: Anonymous commentedExtremely pleasant news!
Comment #135
tim.plunkettComment #136
alexpottCan we also test that the view no longer depends on the thing that has been deleted?
Otherwise we don't have explicit coverage of this.
Comment #137
Lendude@alexpott thanks for the feedback!
So something like this?
Comment #138
Lendude@alexpott rightly pointed out that
\Drupal\Tests\views\Kernel\ViewsConfigDependenciesIntegrationTest
could really use this too, so here we go!Comment #139
Anonymous (not verified) CreditAttribution: Anonymous commentedMaybe in
testDeleteField()
we need something like intestImage()
? Because before delete second field dependency'field.storage.node.field_test'
and test coverage it:Comment #140
Anonymous (not verified) CreditAttribution: Anonymous commentedThis is what I meant in #139.
Comment #141
Lendude@vaplas yeah that's better but would also need a 'before' test, otherwise we just have a negative assertion (so if somebody changed the config name and it didn't get removed, the test would still pass).
So this adds the 'before' test.
Comment #142
Anonymous (not verified) CreditAttribution: Anonymous commented#141 looks nice! I also refreshed #2832558: Add a 'disabled' section to config changes page when removing config and created #2863625: Not found dependency when use field:delta in the view. about an independent problem with delta.
Comment #143
dawehnerThe feedback from @alexpott got addressed, maybe its now time to get it in, finally :)
Comment #145
LendudeUnrelated fail https://www.drupal.org/pift-ci-job/646538
Opened #2868880: Random fails in ContextualFilterTest::testAddContextualFilterUI
Comment #146
alexpottShould have spotted this already but we need a change record. We've got a new interface and way for views plugins to react to dependency removal. Sorry.
Comment #147
LendudeAttempt at a CR: https://www.drupal.org/node/2871981
Comment #148
LendudeComment #149
dawehnerThank you @Lendude!
Comment #150
alexpottCommitted f7520a2 and pushed to 8.4.x. Thanks!
I think there is some scope for committing this to 8.3.x since the interface is an addition and added to a plugin - which by definition is not API. Will ping the other committers.
Comment #152
dawehnerThank you alex for getting this in, finally!
Comment #153
LendudeThanks everybody for working on this!
Comment #154
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #155
dawehnerCan we mention that in the release notes for 8.4?
Comment #156
alexpott@dawehner sure.
Comment #157
alexpottIn discussion about backporting this patch with @xjm and @catch, @xjm raised valid concerns about backporting and committing this patch. These are:
On reflection, I feel that #2832558: Add a 'disabled' section to config changes page when removing config should have been fixed before committing this fix and would have reverted this change but for the fact that the 8.4.x behaviour is probably better for users. However doing things this way around sets a bad precedent.
Comment #158
xjmAdding to #157, splitting the usability issue and review for it out into a followup issue breaks the UX gate, especially in an issue that's specifically about fixing a usability problem.
I think the current usability bug (of disabling the view without warning and not giving even an attentive user information on how to fix it) is less bad than the previous bug (of telling a user that we will delete their view and not having them read it) because they can recover from the former but not the latter. So I don't necessarily think we should revert, but we also should be careful to not skip the usability gate in the future.
Comment #160
Jeff Veit CreditAttribution: Jeff Veit commented8.4 can't come soon enough. I just lost 3 hours work to this UI fail as I tidied up the experiments that got me to my destination. :-(
Comment #161
tomrenner CreditAttribution: tomrenner commentedsubscribing...
Comment #162
jonathanshaw@tomremner you don't need to leave a comment to subscribe (and doing so creates noise for other participants) - instead use the "Follow" toggle link in the right panel.
Comment #163
xjmThe CR for this was never published; took care of that just now.
Comment #164
rosbiffer CreditAttribution: rosbiffer commentedIs this not fixed? I just deleted a content type and was warned it would delete a view so I edited the view and removed the content type, went ahead and deleted it and the view has gone! It was hours of work and I've now discovered my host had dbase backups turned off! Shouldn't the view just have been disabled?
Comment #165
cilefen CreditAttribution: cilefen as a volunteer commented@rosbiffer That is not good. Please open a new bug issue at critical priority and reference the new issue in a comment here. We will be interested to see the steps to reproduce, especially if it can be derived from a clean install. But having a backup on which this data loss could be demonstrated is definitely useful.
Comment #166
scott.browne CreditAttribution: scott.browne commentedDrupal 8 is a pile of trash, they completely ignored everything good about drupal 7.
This just happened to me. A big waste of my time working with 8 and will now need to start again applying changes and hope another bug doesn't completely wipe something.. The entire framework for Drupal 8 is destroying any reputation drupal has.
Comment #167
lokapujyaWhat version of Drupal 8? Also, please report it as suggested in comment #165.
Comment #168
Ammar Qala CreditAttribution: Ammar Qala as a volunteer and commentedBefore deleting any content type first check if the content type is used in any view and make sure to Always show the master display and then check the master display.
To show the master display https://www.drupal.org/docs/8/core/modules/views/manage-display-settings-for-the-views-configuration-screen
Comment #169
cilefen CreditAttribution: cilefen as a volunteer commentedComment #170
tonytheferg CreditAttribution: tonytheferg as a volunteer commentedI don't think this works when deleting fields programmatically.
https://drupal.stackexchange.com/questions/298957/how-to-display-configu...
Comment #171
dqd#170 agree - apart from that (another issue then): I doubt that this is the best approach here. Even a warning, especially between all the other warnings about deleted configs etc - could get overseen easely. And building Views can be very time consuming and frustrating in case of being away forever. We should not remove Views views when an involved field get removed. The issue we came from was that Views views was somewhat broken and warning about a missing field. Which was fine for me and others I discussed about it. Actually even better than what we have atm.
Maybe we should separate the warning from the others in chain and add the infos from #168 could be a good compromise.
Comment #172
Ryanm81 CreditAttribution: Ryanm81 commentedThis is still happening in Drupal 10.1, at least for taxonomy term fields/views.
I must be missing something, but surely by design when you remove a field from a taxonomy/content type it should not then remove views associated with not just that field, but the entire term/content type? If so, is there some sort of recommended way to remove unused fields to preserve keeping any associated views in place?
Comment #173
edlabs CreditAttribution: edlabs commentedIn Drupal 9.5.11, after deleting a float field of a custom content type, the corresponding view having table format can still be edited, saved, enabled, disabled and previewed, but its path returns a "page not found" error.
Comment #174
maxilein CreditAttribution: maxilein commentedAnd please log all the concerned views in recent log messages.