What To Delete?

Submitted by Mile23 on Tue, 09/04/2012 - 17:40

There's been a long-standing issue in the Examples Project, as to whether an implementation of Node API should delete it's content on uninstall.

This is related to other issues about whether modules that implement fields should delete their data from the DB on uninstall. It took a while, but finally Drupal core will prevent you from uninstalling a module that provides a field (or, IIRC, a formatter), so yay, cross that one off the list.

I'd say the solution for Node API would be similar, since any module implementing a content type would depend on node, and so therefore subject to its whims. Node really should be able to deal with any content in its tables, even if the implementing module is disabled. Node should probably disallow uninstalling of modules that have content that belongs to them. Does it?

The solution I think is best is separation of concerns, and I said so in the Examples queue and also one in the Media Gallery queue.

Basically: Have a core module that holds the meat of your implementation, and then other modules that shim this up to the various APIs. So you could have a whatsit module, and also whatsit_node and whatsit_field modules. This makes it easier for Drupal to figure out which data belongs to which implementation, and lets you, for instance, use the field without the content type, if that's your preference.