Closed (fixed)
Project:
Webform
Version:
7.x-4.x-dev
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
10 Feb 2013 at 17:27 UTC
Updated:
15 Apr 2015 at 16:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
quicksketchSince Webform doesn't make any assumptions about what you're using Webform nodes for, uninstalling Webform won't delete your Webform nodes. It also won't delete the Webform content type, but that can be done manually fairly easily.
Webform has the capability to enable functionality on *any* content type, the "webform" content type that is created for you upon installation is just for convenience. I suppose we could check if there are any Webform nodes on the entire site and delete the content type if it's not in use. The current functionality is as designed, but adding a conditional cleanup (if possible) seems like it would be a nice addition.
Comment #2
danchadwick commentedComment #3
marcoscanoRe-opening, if it's closed nobody will work on this :)
As of today with 7.x-4.6 the "problem" still persists. Clean install, clean uninstall, the "webform" content type remains and has to be deleted manually.
+1 for a cleanup task that deletes what was created on installation, if not used.
Comment #4
danchadwick commentedIf you plan on posting a patch to check for any webform nodes at uninstall time and if there are none, delete the webform content type, that's great. Please do re-open with such a patch. Otherwise, this won't be changed.
Comment #5
danchadwick commentedAnd I think we'd better also ensure that no non-standard fields are defined on the content type to prevent:
Comment #6
marcoscanoPatch attached.
BTW, marking a "feature request" as "work as designed" is a bit weird, isn't it? Should be at least "won't fix" if the maintainers are not willing to implement it...
Comment #8
danchadwick commentedI take your point. The problem I face is there is no status that means "This was requested, appropriately considered by the maintainers, and they are happy with the code the way it is now." "Won't fix" sorta implies that the maintainers agree it's bad but have some reason for not wanting to fix it.
The test failure is unrelated to this patch.
1) I would rather see an entity query, rather than a direct query to the tables. There's an API for that. :)
2) Will the body field prevent this from working? Have you tried it? I know that title is an "extra field", but I'm not sure about body.
Comment #9
danchadwick commentedLet's bring that version forward a couple of years. :)
Comment #10
marcoscanoRight! I was testing it on an installation without "body" fields, which is not normally the case, sorry. Attached the revised patch.
In any case, after giving it a little more thought, I realised that perhaps we should go the opposite way and also delete all nodes of type "webform" on module uninstall! When we uninstall the module we have a message like:
This means that after reading this message and clicking "OK", I'm aware that all data related to the module will be erased (not only the config).
Also, I'm not sure if the situation we are trying to "respect" keeping the nodes is a normal use case: it means that someone wants to use the "webform" content type nodes without the webform functionality (because the module is no longer present!)...
Comment #11
danchadwick commentedAaaaah, I don't think so on deleting node data. Too much downside and not enough upside. Remember -- they can delete themselves easily via the UI. I'm also not sure how you create an uninstall message. A form alter wouldn't help drush.
I prefer range(0, 1) on principle to count() because of the database work required for count on some engines. We don't need to know the exact number, just whether it is > 0. Some engines may optimize count() when there's an index, but others may require a complete scan of every row that matches the index -- a potentially long operation. Since there is no order clause, range(0, 1) can return the first one it finds.
Comment #12
danchadwick commentedTests failed because they were run on 7.x-4.0-alpha6. May I please have the last 30 minutes of my life back.
Comment #13
danchadwick commentedTests don't cover this. I tweaked your code a tiny bit. Thanks for the patch.
Committed to 7.x-4.x.
Comment #14
danchadwick commentedNeeds port to D8.
Comment #16
mitchalbert commentedHi,
Here is a patch for drupal 8.
You also need this patch: https://www.drupal.org/node/2460185 <- fix for webform_node_type_delete
Comment #17
danchadwick commentedComment #18
fenstratCommitted and pushed to 8.x-4.x. Thanks!
Thanks for the patch in #16 @mitchalbert however it was missing the additional fields check, node_type_load is deprecated, and it also had a few Drupal coding standards issues. I've fixed these. For the field check, from searching and asking in IRC, there doesn't seem to be a handy equivalent to field_info_instances() hence the use of array_diff_assoc to get just the configured fields (i.e. non base fields).