The question isn't *how* to delete them. The question is *should* we delete them. It does seem a little presumptuous to just delete all of the user-entered content. On the other hand, we can't really uninstall the schema if we are leaving the nodes -- that just leaves a heap of semi-functional (or non-functional) detritus. I'm imagining irate users who try re-installing the module only to discover that they have lost hundreds of quiz question nodes. On the other hand, uninstalling the schema (which, for quiz, includes tables for fields that augment the standard node fields) will cripple the nodes anyway. If that is going to cause irritation, then we might as well just delete the entire node. So the question is quite simply this: Should modules that provide their own content types delete all content of said types when the module is uninstalled? I'm remembering a particularly frustrating experience trying to uninstall a desktop application. The uninstaller was broken, and I had all kinds of mostly broken junk left on my system that I couldn't get rid of. I would hate to impose that experience on any Drupal user. As chx points out, removing all of the content may leave a site with broken views. As sivaji points out, it can mess with menus and other Drupal structures as well. So we have cases where removing nodes is going to have negative side-effects. And then, again, we have the case where we leave the nodes, but remove the module-specific data that is stored in the module-specific tables. That, too, leaves Drupal broken. So which kind of broken do we want? Matt On Tue, Apr 28, 2009 at 4:12 PM, Charlie Gordon <cwgordon7@gmail.com> wrote:
In order to delete nodes of a certain type (say, "quiz"), you can execute a database query of the following form:
$result = db_query("SELECT nid FROM {node} WHERE type = '%s'", 'quiz'); while ($node = db_fetch_object($result)) { node_delete($node->nid); }
However, this will encounter several scaling problems for sites with many quiz nodes. You may want to investigate using the batch API for something of this scale.
On the other hand, you probably shouldn't be deleting the nodes quiz module created - "uninstalling" a module means removing any module settings or data stored within the module: core poll module, for example, does not delete its nodes upon uninstalling. You seem to be aware of this in your message, and express concern that quiz nodes promoted to the front page still exist; I would argue that it's not the quiz module's place to be handling this problem.
This opens up a larger debate over whether node-type modules should delete their own nodes upon deletion. In this case, I'd advise following core's example and not worrying about orphaned quiz nodes.
-Charlie
sivaji j.g wrote:
Hello folks
I am a gsoc student working on quiz module. Quiz module treats quiz and its question types (multichoice, true/false etc) as a Drupal nodes. I would like to know whether i can delete a nodes specific to quiz module in hook_uninstall. My mentor and current maintainer of quiz module mbutcher is not sure about this. I have already asked this question in #drupal and came to know that core modules never deletes thier node with type story, page etc but nobody is sure about nodes specific modules.
If you suggest me to leave quiz nodes untouched like core modules imagine the situation where i have some primary links to quiz nodes and quiz nodes promoted to front page they remains active even if i uninstall quiz module, how should i handle this situation ? or shall i unpublish the quiz nodes to tackle this situation ?
-- Thanks a lot ----------------------------------------- http://ubuntuslave.blogspot.com/