D6 Cleaning up on module uninstall
I have my module -install- working fine...creating the needed vocabulary, cck content type with fields, adding the content type to the vocabulary. Now I'm working on the uninstall, and the seemingly infinite cleanup that's needed, not that anyone would ever want to remove my module, once installed! I believe I have the vocabulary and its data, and the cck content type and its data accounted for with: taxonomy_del_vocabulary($vid); drupal_load('module', 'content'); content_notify('uninstall', 'my_module'); and that brings me to nodes et al. There will be nodes (and node revisions) to be removed, and each node can have multiple field instances (cck image field). I don't seem to see a magic function that, given a node type, will remove all associated node data for that type. Also, I think I should remove the files that were uploaded as cck image content. Any tips on a good example of a complete "undo"? :) -- Ayen Designs 388 Bullsboro Drive #105 · Newnan, Georgia 30263 404-271-9734 Web:ayendesigns.com <http://ayendesigns.com> Blog: theAccidentalCoder.com <http://theaccidentalcoder.com> Drupal: j. ayen green <http://drupal.org/user/367108> IRQ: j_ayen_green IM (Yahoo) baalwww (MSN) baalwww@yahoo.com Skype: ayendesigns Ayen Designs is a tradename of the computer services division of
There isn't really a complete undo, no. You can run a query of all nodes of your type and call node_delete() on each of them in turn, though. That will clear up the fields and I believe even the images. On Wed, Jan 26, 2011 at 2:48 PM, <jeff@ayendesigns.com> wrote:
I have my module -install- working fine...creating the needed vocabulary, cck content type with fields, adding the content type to the vocabulary. Now I'm working on the uninstall, and the seemingly infinite cleanup that's needed, not that anyone would ever want to remove my module, once installed!
I believe I have the vocabulary and its data, and the cck content type and its data accounted for with:
taxonomy_del_vocabulary($vid);
drupal_load('module', 'content'); content_notify('uninstall', 'my_module');
and that brings me to nodes et al. There will be nodes (and node revisions) to be removed, and each node can have multiple field instances (cck image field). I don't seem to see a magic function that, given a node type, will remove all associated node data for that type. Also, I think I should remove the files that were uploaded as cck image content. Any tips on a good example of a complete "undo"? :)
--
Ayen Designs 388 Bullsboro Drive #105 · Newnan, Georgia 30263 404-271-9734 Web:ayendesigns.com Blog: theAccidentalCoder.com <http://theaccidentalcoder.com> Drupal: j. ayen green <http://drupal.org/user/367108> IRQ: j_ayen_green IM (Yahoo) baalwww (MSN) baalwww@yahoo.com Skype: ayendesigns
Ayen Designs is a tradename of the computer services division of
-- John Fiala www.jcfiala.net
Sort of a complete undo then...I just need to provide and pop the stack :) Thanks, John.
John Fiala wrote:
There isn't really a complete undo, no. You can run a query of all nodes of your type and call node_delete() on each of them in turn, though. That will clear up the fields and I believe even the images.
$result = db_query("SELECT nid FROM {node} where type='{whatever my custom type is}'"); while ($row=db_fetch_object($result)){ node_delete($row->nid); } If your talking about images through imagefield, then that will delete the files also. One thing to note: Depending on how many nodes you have, this can choke. It is generally best to do bulk deletes like this through the batch api in batches of 50 or so. Jamie Holly http://www.intoxination.net http://www.hollyit.net On 1/26/2011 4:48 PM, jeff@ayendesigns.com wrote:
I have my module -install- working fine...creating the needed vocabulary, cck content type with fields, adding the content type to the vocabulary. Now I'm working on the uninstall, and the seemingly infinite cleanup that's needed, not that anyone would ever want to remove my module, once installed!
I believe I have the vocabulary and its data, and the cck content type and its data accounted for with:
taxonomy_del_vocabulary($vid);
drupal_load('module', 'content'); content_notify('uninstall', 'my_module');
and that brings me to nodes et al. There will be nodes (and node revisions) to be removed, and each node can have multiple field instances (cck image field). I don't seem to see a magic function that, given a node type, will remove all associated node data for that type. Also, I think I should remove the files that were uploaded as cck image content. Any tips on a good example of a complete "undo"? :)
--
Ayen Designs 388 Bullsboro Drive #105 · Newnan, Georgia 30263 404-271-9734 Web:ayendesigns.com <http://ayendesigns.com> Blog: theAccidentalCoder.com <http://theaccidentalcoder.com> Drupal: j. ayen green <http://drupal.org/user/367108> IRQ: j_ayen_green IM (Yahoo) baalwww (MSN) baalwww@yahoo.com Skype: ayendesigns
Ayen Designs is a tradename of the computer services division of
Ah, good point, thanks. I don't think the node count will be an issue, but the total number of files to be deleted could be.
Jamie Holly wrote:
$result = db_query("SELECT nid FROM {node} where type='{whatever my custom type is}'"); while ($row=db_fetch_object($result)){ node_delete($row->nid); }
If your talking about images through imagefield, then that will delete the files also.
One thing to note: Depending on how many nodes you have, this can choke. It is generally best to do bulk deletes like this through the batch api in batches of 50 or so.
Do what core does. Do not remove nodes on uninstall. That's better left for a batch process, which is not appropriate for uninstall. Dave Reid dave@davereid.net On Wed, Jan 26, 2011 at 3:48 PM, <jeff@ayendesigns.com> wrote:
I have my module -install- working fine...creating the needed vocabulary, cck content type with fields, adding the content type to the vocabulary. Now I'm working on the uninstall, and the seemingly infinite cleanup that's needed, not that anyone would ever want to remove my module, once installed!
I believe I have the vocabulary and its data, and the cck content type and its data accounted for with:
taxonomy_del_vocabulary($vid);
drupal_load('module', 'content'); content_notify('uninstall', 'my_module');
and that brings me to nodes et al. There will be nodes (and node revisions) to be removed, and each node can have multiple field instances (cck image field). I don't seem to see a magic function that, given a node type, will remove all associated node data for that type. Also, I think I should remove the files that were uploaded as cck image content. Any tips on a good example of a complete "undo"? :)
--
Ayen Designs 388 Bullsboro Drive #105 · Newnan, Georgia 30263 404-271-9734 Web:ayendesigns.com Blog: theAccidentalCoder.com <http://theaccidentalcoder.com> Drupal: j. ayen green <http://drupal.org/user/367108> IRQ: j_ayen_green IM (Yahoo) baalwww (MSN) baalwww@yahoo.com Skype: ayendesigns
Ayen Designs is a tradename of the computer services division of
But what about the fact that the content type of the node, the field definition of the fields within it, and the taxonomy vocabulary that categorizes them will all be gone? What if someone attempts to edit?
Do what core does. Do not remove nodes on uninstall. That's better left for a batch process, which is not appropriate for uninstall.
Dave Reid dave@davereid.net <mailto:dave@davereid.net>
On Wed, Jan 26, 2011 at 3:48 PM, <jeff@ayendesigns.com <mailto:jeff@ayendesigns.com>> wrote:
I have my module -install- working fine...creating the needed vocabulary, cck content type with fields, adding the content type to the vocabulary. Now I'm working on the uninstall, and the seemingly infinite cleanup that's needed, not that anyone would ever want to remove my module, once installed!
I believe I have the vocabulary and its data, and the cck content type and its data accounted for with:
taxonomy_del_vocabulary($vid);
drupal_load('module', 'content'); content_notify('uninstall', 'my_module');
and that brings me to nodes et al. There will be nodes (and node revisions) to be removed, and each node can have multiple field instances (cck image field). I don't seem to see a magic function that, given a node type, will remove all associated node data for that type. Also, I think I should remove the files that were uploaded as cck image content. Any tips on a good example of a complete "undo"? :)
--
Ayen Designs 388 Bullsboro Drive #105 · Newnan, Georgia 30263 404-271-9734 Web:ayendesigns.com <http://ayendesigns.com> Blog: theAccidentalCoder.com <http://theaccidentalcoder.com> Drupal: j. ayen green <http://drupal.org/user/367108> IRQ: j_ayen_green IM (Yahoo) baalwww (MSN) baalwww@yahoo.com <mailto:baalwww@yahoo.com> Skype: ayendesigns
Ayen Designs is a tradename of the computer services division of
Hi, You shouldn't remove the taxonomy on uninstall, as people may be using the taxonomy you created for another purpose, and what you originally intended. Just on the uninstall let the user know that they should be deleted. If your module defines the content type Drupal will handle the fact that the definition is missing, and the admin can clean up all the nodes, and other definitions. Gordon. On 27/01/2011, at 11:09 AM, jeff@ayendesigns.com wrote:
But what about the fact that the content type of the node, the field definition of the fields within it, and the taxonomy vocabulary that categorizes them will all be gone? What if someone attempts to edit?
Do what core does. Do not remove nodes on uninstall. That's better left for a batch process, which is not appropriate for uninstall.
Dave Reid dave@davereid.net
On Wed, Jan 26, 2011 at 3:48 PM, <jeff@ayendesigns.com> wrote: I have my module -install- working fine...creating the needed vocabulary, cck content type with fields, adding the content type to the vocabulary. Now I'm working on the uninstall, and the seemingly infinite cleanup that's needed, not that anyone would ever want to remove my module, once installed!
I believe I have the vocabulary and its data, and the cck content type and its data accounted for with:
taxonomy_del_vocabulary($vid); drupal_load('module', 'content'); content_notify('uninstall', 'my_module');
and that brings me to nodes et al. There will be nodes (and node revisions) to be removed, and each node can have multiple field instances (cck image field). I don't seem to see a magic function that, given a node type, will remove all associated node data for that type. Also, I think I should remove the files that were uploaded as cck image content. Any tips on a good example of a complete "undo"? :) -- <ayenlogo.jpeg> Ayen Designs 388 Bullsboro Drive #105 · Newnan, Georgia 30263 404-271-9734 Web:ayendesigns.com Blog: theAccidentalCoder.com Drupal: j. ayen green IRQ: j_ayen_green IM (Yahoo) baalwww (MSN) baalwww@yahoo.com Skype: ayendesigns
Ayen Designs is a tradename of the computer services division of <acmelogo.jpeg>
Good points from you and everyone else. On a tangent to this example, I think about the "completely uninstall" and "lose all data" messages, and that apparently the accepted way of doing it leaves many footprints. Sort of like when I have Windows remove an app and yet there are files and registry entries left all over the place, though in that case I don't think its by design. I don't know if this is also the case in D7, but if so, it might be fodder for a Cleanup module that accepts registration of all a module's pieces and then offers the user a choice between a 'standard' uninstall and a truly full one.
Hi,
You shouldn't remove the taxonomy on uninstall, as people may be using the taxonomy you created for another purpose, and what you originally intended. Just on the uninstall let the user know that they should be deleted.
If your module defines the content type Drupal will handle the fact that the definition is missing, and the admin can clean up all the nodes, and other definitions.
Gordon.
Jeff, as soon as I saw this I started thinking about a content removal add-on for the Util package, using the Batch API. Also, I understand that D7 has fixed this but pre-D7, blocks never went away either (unless, like me, the devloper explicitly did it). Nancy Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr. ________________________________ From: "jeff@ayendesigns.com" <jeff@ayendesigns.com> To: development@drupal.org Sent: Wed, January 26, 2011 7:31:41 PM Subject: Re: [development] D6 Cleaning up on module uninstall Good points from you and everyone else. On a tangent to this example, I think about the "completely uninstall" and "lose all data" messages, and that apparently the accepted way of doing it leaves many footprints. Sort of like when I have Windows remove an app and yet there are files and registry entries left all over the place, though in that case I don't think its by design. I don't know if this is also the case in D7, but if so, it might be fodder for a Cleanup module that accepts registration of all a module's pieces and then offers the user a choice between a 'standard' uninstall and a truly full one.
Hi,
You shouldn't remove the taxonomy on uninstall, as people may be using the taxonomy you created for another purpose, and what you originally intended. Just on the uninstall let the user know that they should be deleted.
If your module defines the content type Drupal will handle the fact that the definition is missing, and the admin can clean up all the nodes, and other definitions.
Gordon.
:) I vote for naming it Scrubbing Bubbles
Jeff, as soon as I saw this I started thinking about a content removal add-on for the Util package, using the Batch API. Also, I understand that D7 has fixed this but pre-D7, blocks never went away either (unless, like me, the devloper explicitly did it).
/*Nancy*/
So, looking at other modules that have content types, it seems that when they uninstall they do a content_notify with uninstall as the action. When I do this, everything indicates a clean uninstall otherwise, but nothing really seems to change regarding the cck info, in that the field table, content type table and entry in node_type all remain. Is this right? It certainly complicates the install logic in that even though it's my content type and field, I can't assume that they don't exist when I install.
http://api.drupal.org/api/drupal/modules--node--node.module/function/node_ty... Nancy Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr. ________________________________ From: "jeff@ayendesigns.com" <jeff@ayendesigns.com> To: development@drupal.org Sent: Wed, January 26, 2011 9:42:22 PM Subject: Re: [development] D6 Cleaning up on module uninstall So, looking at other modules that have content types, it seems that when they uninstall they do a content_notify with uninstall as the action. When I do this, everything indicates a clean uninstall otherwise, but nothing really seems to change regarding the cck info, in that the field table, content type table and entry in node_type all remain. Is this right? It certainly complicates the install logic in that even though it's my content type and field, I can't assume that they don't exist when I install.
Nancy, that will get rid of the node type entry, but not the cck content-field- and content-type tables. I should delete those, or is that something else that should remain after the uninstall?
http://api.drupal.org/api/drupal/modules--node--node.module/function/node_ty...
/*Nancy*/
One way to avoid this whole problem would be to adopt an everything in code process (either through features or leaning heavily on the installation api module and bulk export modules). That way, updates are all like module updates. See http://nuvole.org/blog/2010/aug/24/features-based-development-workflow The technique works whether you use features or not. Victor Kane http://awebfactory.com.ar http://drupal.org/project/pft On Thu, Jan 27, 2011 at 1:21 AM, <jeff@ayendesigns.com> wrote:
Nancy, that will get rid of the node type entry, but not the cck content-field- and content-type tables. I should delete those, or is that something else that should remain after the uninstall?
http://api.drupal.org/api/drupal/modules--node--node.module/function/node_ty...
*Nancy*
Good point. I think the first decision someone needs to make in this case is whether they want their content type and fields to depend on CCK being present. It's possible either way, of course, but a whole lot more work.
Victor wrote:
One way to avoid this whole problem would be to adopt an everything in code process (either through features or leaning heavily on the installation api module and bulk export modules).
That way, updates are all like module updates.
See http://nuvole.org/blog/2010/aug/24/features-based-development-workflow
The technique works whether you use features or not.
You can easily check to see if any other node types are using the vocabulary and issue a warning that you cannot delete it because it is being used in other content. Generally someone is going to uninstall soon after install, so the risk is minimal. Nancy Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr. ________________________________ From: Gordon Heydon <gordon@heydon.com.au> To: development@drupal.org Sent: Wed, January 26, 2011 7:17:48 PM Subject: Re: [development] D6 Cleaning up on module uninstall Hi, You shouldn't remove the taxonomy on uninstall, as people may be using the taxonomy you created for another purpose, and what you originally intended. Just on the uninstall let the user know that they should be deleted. If your module defines the content type Drupal will handle the fact that the definition is missing, and the admin can clean up all the nodes, and other definitions. Gordon. On 27/01/2011, at 11:09 AM, jeff@ayendesigns.com wrote: But what about the fact that the content type of the node, the field definition of the fields within it, and the taxonomy vocabulary that categorizes them will all be gone? What if someone attempts to edit?
Do what core does. Do not remove nodes on uninstall. That's better left for a batch process, which is not appropriate for uninstall.
Dave Reid dave@davereid.net
On Wed, Jan 26, 2011 at 3:48 PM, <jeff@ayendesigns.com> wrote:
I have my module -install- working fine...creating the needed vocabulary, cck content type with fields, adding the content type to the vocabulary. Now I'm working on the uninstall, and the seemingly infinite cleanup that's needed, not that anyone would ever want to remove my module, once installed!
I believe I have the vocabulary and its data, and the cck content type and its data accounted for with:
taxonomy_del_vocabulary($vid); drupal_load('module', 'content'); content_notify('uninstall', 'my_module');
and that brings me to nodes et al. There will be nodes (and node revisions) to be removed, and each node can have multiple field instances (cck image field). I don't seem to see a magic function that, given a node type, will remove all associated node data for that type. Also, I think I should remove the files that were uploaded as cck image content. Any tips on a good example of a complete "undo"? :)
--
<ayenlogo.jpeg> Ayen Designs 388 Bullsboro Drive #105 · Newnan, Georgia 30263 404-271-9734 Web:ayendesigns.com Blog: theAccidentalCoder.com Drupal: j. ayen green IRQ: j_ayen_green IM (Yahoo) baalwww (MSN) baalwww@yahoo.com Skype: ayendesigns
Ayen Designs is a tradename of the computer services division of
<acmelogo.jpeg>
participants (7)
-
Dave Reid -
Gordon Heydon -
Jamie Holly -
jeff@ayendesigns.com -
John Fiala -
nan wich -
Victor Kane