I had webform installed and then decided to deaktivate it. Since it was still listed under create content I went on to uninstall it, but it continued to be listed. I then removed the module folder, which got it unlisted from the modules page, but it was still listed to be used to create content. When I use it, I can create a node with the type webform. I don't think this is how it is supposed to be.

Comments

quicksketch’s picture

Title: Disabled and uninstalled Webform can still be used! » Delete Webform content type if not in use upon uninstall
Category: bug » feature

Since 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.

danchadwick’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)
marcoscano’s picture

Status: Closed (works as designed) » Active

Re-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.

danchadwick’s picture

Status: Active » Closed (works as designed)

If 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.

danchadwick’s picture

And I think we'd better also ensure that no non-standard fields are defined on the content type to prevent:

  1. Install webform
  2. Do a bunch of work setting up your fields.
  3. Oh, wrong version of webform!
  4. Uninstall
  5. Reinstall
  6. Crap, now I have to create those 20 fields again. Darn!
marcoscano’s picture

Status: Closed (works as designed) » Needs review
StatusFileSize
new943 bytes

Patch 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...

Status: Needs review » Needs work

The last submitted patch, 6: Delete-webform-content-type-on-uninstall-1913500-6.patch, failed testing.

danchadwick’s picture

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...

I 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.

danchadwick’s picture

Version: 7.x-4.0-alpha6 » 7.x-4.x-dev

Let's bring that version forward a couple of years. :)

marcoscano’s picture

Right! 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:

The following modules will be completely uninstalled from your site, and all data from these modules will be lost!

Webform

Would you like to continue with uninstalling the above?

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!)...

danchadwick’s picture

Aaaaah, 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.

danchadwick’s picture

Status: Needs work » Needs review

Tests failed because they were run on 7.x-4.0-alpha6. May I please have the last 30 minutes of my life back.

danchadwick’s picture

Status: Needs review » Fixed
StatusFileSize
new1.27 KB

Tests don't cover this. I tweaked your code a tiny bit. Thanks for the patch.

Committed to 7.x-4.x.

danchadwick’s picture

Version: 7.x-4.x-dev » 8.x-4.x-dev
Category: Feature request » Task
Status: Fixed » Patch (to be ported)

Needs port to D8.

mitchalbert’s picture

Hi,

Here is a patch for drupal 8.

You also need this patch: https://www.drupal.org/node/2460185 <- fix for webform_node_type_delete

danchadwick’s picture

Status: Patch (to be ported) » Needs review
fenstrat’s picture

Version: 8.x-4.x-dev » 7.x-4.x-dev
Category: Task » Feature request
Status: Needs review » Fixed

Committed 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).

  • fenstrat committed 360ff88 on 8.x-4.x
    Issue #1913500 by marcoscano, DanChadwick, fenstrat, mitchalbert: Delete...

The last submitted patch, 10: Delete-webform-content-type-on-uninstall-1913500-10.patch, failed testing.

Status: Fixed » Closed (fixed)

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