Be more graceful when editing nodes with disabled node types

sai571 - March 13, 2009 - 03:45
Project:Drupal
Version:7.x-dev
Component:node system
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work
Issue tags:Needs tests, Needs text review, Novice, Usability
Description

Hello,

I'm a new bie, I've observed that when i enable forum/poll module and create a forum( and then a topic)/poll and then disable the forum/poll module. The nodes which are related to those modules are not being disabled automatically. This is creating problems when those nodes of the types are displayed and we try to edit them. One such problem occurs when we edit the node type the appropriate form is not being displayed, rather a error message is being displayed saying "there is no forum_node_form() function".

Please check this bug and if possible do delete the node types corressponding to the modules that are being disabled.

#1

VM - March 17, 2009 - 17:17
Category:bug report» support request
Priority:critical» normal
Assigned to:sai571» Anonymous
Status:active» won't fix

nodes aren't deleted when a module is disabled. The data is only deleted when you use the uninstall tab at the top of administer -> modules.

This is done on purpose and is not a bug as far as I can tell, as there are times when disabling a module is necessary, ie. upgrades and you wouldn't want sites to lose their data. If you don't want the data there any longer you must uninstall the module not simply disable it.

#2

sai571 - March 17, 2009 - 17:52

Hello again,

I've checked forum.install file for hook_unistall implementation for the forum module.

<?php
/**
* Implementation of hook_uninstall().
*/
function forum_uninstall() {
 
// Load the dependent Taxonomy module, in case it has been disabled.
 
drupal_load('module', 'taxonomy');

 
// Delete the vocabulary.
 
$vid = variable_get('forum_nav_vocabulary', '');
 
taxonomy_del_vocabulary($vid);

 
db_query('DROP TABLE {forum}');
 
variable_del('forum_containers');
 
variable_del('forum_nav_vocabulary');
 
variable_del('forum_hot_topic');
 
variable_del('forum_per_page');
 
variable_del('forum_order');
 
variable_del('forum_block_num_0');
 
variable_del('forum_block_num_1');
}
?>

You can see that forum module drops only the "FORUM" table, but it doesn't delete the rows it had created in "NODE" table, which may be displayed even after the forum is disabled and unintsalled (say through search).

#3

sai571 - March 17, 2009 - 18:10
Status:won't fix» active

#4

Dave Reid - March 17, 2009 - 18:57
Title:This bug is there in forum, poll modules (could be present in other modules also).» Be more graceful when editing nodes with disabled node types
Version:6.9» 7.x-dev
Issue tags:-forum bug+Usability

Needs to be fixed in 7 (CVS HEAD) first, then backport if necessary.

#5

karschsp - March 18, 2009 - 03:14
Issue tags:+Novice

tagging for the novice queue. shouldn't be too hard to add something to forum.install to clean up nodes of type 'forum'

#6

Dave Reid - March 18, 2009 - 03:30

Thing is, we do not delete existing content. If you disable the blog module, your blog content still shows up. Forum should work the same. Maybe our expectations should change? The first thing that needs to happen is get rid of the nasty error at node/x/edit of a node of a disabled content type.

#7

karschsp - March 18, 2009 - 03:40

sorry, misread the thread. Hmmm...I guess the question is, what's the expected behavior? Should you be able to edit content that's of a type that's no longer enabled? Should it catch the fact that forum no longer is enabled and present a friendlier message like:

"This node was created using xyz module, which is no longer available. Please visit the modules section to enable xyz."

Would that work? Is that even feasible?

#8

Dave Reid - March 18, 2009 - 04:54
Status:active» needs review

I've been playing around with this a little bit. We basically have two options:

A. The text at admin/build/modules/uninstall says: "The uninstall process removes all data related to a module." That already includes the content types, but we should also make sure all content associated with that type is also removed. This might lead to unwanted data loss scenarios: user didn't realize that the blog entry content type was related to the blog.module. Poof! All blog content gone!
B. Add a condition to node_page_edit() that checks if the form ID type_node_form doesn't exist. Intercept, throw up a drupal_set_message, and stop the form from being rendered.

Option B seems the most logical, so I created a quick patch to see how it would look compared to the current error message.

Heh...my Amazon search for "Night Watch" from chx's tweet has been saved for all. :)

AttachmentSizeStatusTest resultOperations
400450-disabled-content-types-be-nice-D7.patch1.54 KBIdleFailed: Failed to run tests.View details | Re-test
400450-before.png121.48 KBIgnoredNoneNone
400450-after.png103.44 KBIgnoredNoneNone

#9

sai571 - March 18, 2009 - 07:29

Thank you for your support.

Yes Option B, as stated by Dave Reid would be more graceful and less lossy when the module is only disabled. But when the module is "Uninstalled" all the data that's related to the module should be deleted ( i mean the nodes corressponding to the module in the 'node' table).

Why can't we fix it in drupal 6.x rather than going for drupal 7.x??

#10

ainigma32 - March 18, 2009 - 08:41
Category:support request» feature request

Why can't we fix it in drupal 6.x rather than going for drupal 7.x

That's because this is a new feature and new features are always implemented in HEAD (i.e. 7.x) and then back ported to earlier versions.

Changing the category to feature request to reflect that.

- Arie

#11

mr.baileys - March 18, 2009 - 15:14
Issue tags:+Needs tests

Quick review:

  1. You are using return drupal_get_page($page); in node_page_edit in a place where $page might be undefined (if the if access-branch is not used).
  2. I guess since this is a new scenario, we should add a test for this?

#12

catch - March 18, 2009 - 23:09

I don't think we should delete nodes when we uninstall the forum module - nodes belong to the node module, only their type and some metadata belongs to the forum module.

Screenshot looks good, no patch review brain left tonight so just subscribing for now.

#13

Arancaytar - April 28, 2009 - 15:56
Status:needs review» needs work

For a more readable logical structure, I would suggest reversing the condition so the normal case comes first, and the exception case comes second. First check if the type exists, then if it does return the form - and otherwise return the error page.

---

This fixes the undefined function error on the edit page - but nodes can still be displayed. Should we leave it at this, or hide these orphaned nodes from view completely?

#14

Shawn DeArmond - May 28, 2009 - 04:49

Here's a patch with Arancaytar's suggestion of reversing the condition.

I think that nodes that are created should remain. Nodes belong to the Node module, as catch says.

AttachmentSizeStatusTest resultOperations
400450-disabled-content-types-be-nice-D7.patch1.14 KBIdleFailed: Failed to install HEAD.View details | Re-test

#15

Shawn DeArmond - June 9, 2009 - 23:26
Status:needs work» needs review

bot?

#16

catch - June 11, 2009 - 10:29
Issue tags:+Needs text review

I think we should reverse the sentence structure to say that the content can't be edited first, then explain why and how to fix it. Having said that, I tried to rewrite it and it's a bit tricky - got this far:

This content cannot be edited because the content type @type has been disabled or removed.

#17

Shawn DeArmond - June 11, 2009 - 23:58

Yeah, I like catch's wording better. Here's a patch.

AttachmentSizeStatusTest resultOperations
400450-disabled-content-types-be-nice-D7-v2.patch1.08 KBIdleFailed: Failed to apply patch.View details | Re-test

#18

System Message - June 24, 2009 - 01:20
Status:needs review» needs work

The last submitted patch failed testing.

#19

Bojhan - June 24, 2009 - 13:19
Status:needs work» needs review

Really Mr.Bot?

#20

System Message - June 28, 2009 - 03:55
Status:needs review» needs work

The last submitted patch failed testing.

#21

Bojhan - June 28, 2009 - 21:28

Stupid bot, it is giving me green! I do not get this.

#22

andypost - June 28, 2009 - 21:41
Status:needs work» needs review

Some bots was broken

#23

arianek - August 14, 2009 - 00:09

patch applied cleanly. reuploading for test bot - this is a nice looking fix, though i can't really critique the code itself.

AttachmentSizeStatusTest resultOperations
400450-disabled-content-types-be-nice-D7-v2.patch1.08 KBIdleFailed: Failed to apply patch.View details | Re-test

#24

Shawn DeArmond - August 17, 2009 - 18:56
Status:needs review» needs work

This patch applies okay to the latest Drupal 7, but it produces a WSOD when going to the edit screen. I'm going to work on this today.

It would be really nice if it were possible to, if the content type is deleted, allow the user to migrate the node to another content type that still exists. Not sure what's involved with that, though.

#25

Bojhan - August 17, 2009 - 18:25

A lot, a lot is involved with that.

#26

Shawn DeArmond - August 17, 2009 - 18:38
Status:needs work» needs review

Okay, this one should work.

I'll ignore the content type migration for the time being.

AttachmentSizeStatusTest resultOperations
400450-disabled-content-types-be-nice-D7-v3.patch1.09 KBIdleFailed: 12165 passes, 2 fails, 0 exceptionsView details | Re-test

#27

System Message - August 22, 2009 - 09:55
Status:needs review» needs work

The last submitted patch failed testing.

#28

Shawn DeArmond - September 11, 2009 - 20:35
Status:needs work» needs review

Bad bot?

AttachmentSizeStatusTest resultOperations
400450-disabled-content-types-be-nice-D7-v3_1.patch1.09 KBIdleFailed: Failed to apply patch.View details | Re-test

#29

joshmiller - September 13, 2009 - 16:14

What if we set all forum nodes after uninstallation to "unpublished" ?

#30

Shawn DeArmond - September 15, 2009 - 00:09

The nodes (in general) do function fine as is, even without a defined content type. It's just when you try to edit them that the confusing error message appears. This patch is just supposed to make it a little more friendly.

#31

System Message - October 11, 2009 - 20:10
Status:needs review» needs work

The last submitted patch failed testing.

#32

Shawn DeArmond - October 12, 2009 - 18:14
Status:needs work» needs review

What's up, bot? Let's try it again.

#33

System Message - October 12, 2009 - 18:30
Status:needs review» needs work

The last submitted patch failed testing.

#34

Shawn DeArmond - October 12, 2009 - 20:25

Okay, here's a re-rolled patch, but it's still not perfect. An error message appears when the node is displayed in teaser mode on the home page.

Here's what it says:

Notice: Undefined index: teaser in field_default_view() (line 65 of /path/to/drupal/modules/field/field.default.inc).

AttachmentSizeStatusTest resultOperations
400450-disabled-content-types-be-nice-D7-v4.patch1.19 KBIgnoredNoneNone
 
 

Drupal is a registered trademark of Dries Buytaert.