I've no idea where this problem is rooted in, but...

Steps to reproduce:
- Enable the Blog module.
- Disable the Blog module.
- Click Create content, observe that Blog entry is still one of the menu items. (When you click it, you get no Title/Body... just a Log message field and the other options. Funky.)
- Go to admin/content/taxonomy/add/vocabulary and notice that Blog entry is still one of the node types you can assign.

admin/content/types correctly reflects its absence.

Comments

pwolanin’s picture

Yes, I see this too.

checking the DB: {node_type} still contains type blog after the module is disabled
however, node_type.module == 'blog', so it seems like it shouldn't go in the menu at least, based on the code in node_menu()

node_menu() checks:

function_exists($type->module .'_form')

and this is the *same* check used by function node_overview_types(). In this latter case, blog doesn't show up after being disabled.

at least with my patched menu system, the menu entry goes away when I do another menu_rebuild(). This suggests something problematic about when the menu_rebuild is happening. ALos, seems like 'blog' should be deleted form the table?

pwolanin’s picture

http://api.drupal.org/api/HEAD/function/_node_types_build

should probably delete form the table disabled node types?

webernet’s picture

pwolanin’s picture

Yes, that looks related. A big part of the problem is that node module isn't tracking which actual module is declaring a node type. It just has the (badly mis-named) 'module' field which should really be called 'base' or 'prefix' or something else.

As far as the menu part, the fundamental problem still seems to be that node_get_types returns 'blog' in the list and the function blog_form() still exists in memory. Since the 'base' could just as well be zzz_ as blog_, there is no way to fix this in the menu system.

Another part of the problem- hook_disable() is only called for the specific module being disabled. I guess a #submit function could be added to the module form??? That's a little ugly however....

pwolanin’s picture

StatusFileSize
new284 bytes

The easiest way to fix this (though not the best) - implement hook_disable for each node-type module.

Attached patch for blog

pwolanin’s picture

Status: Active » Needs review
StatusFileSize
new1.19 KB

patch for forum and poll (note I don't know how to get all 3 in one patch since blog.install doesn't exist)

ChrisKennedy’s picture

Peter - see http://drupal.org/patch/create under "Adding/Deleting files".

pwolanin’s picture

StatusFileSize
new1.59 KB

Thanks!

pwolanin’s picture

Anyone? Either we need a simple fix like this (manually remove), or someone needs to take on a more thoroough re-write before the code freeze.

yched’s picture

StatusFileSize
new919 bytes

What about this : in node_types_rebuild(), check the modules do exist and remove the record in {node_type} is not.

Attached patch does that

yched’s picture

let me start again : in node_types_rebuild(), check the modules do exist and remove the record in {node_type} *if* not.

pwolanin’s picture

Status: Needs review » Needs work

can't work - the 'module' field is badly mis-named (should be named 'hook' or something else). It does *NOT* have any correspondance to the actual name of the module. That's why this is so frustrating!

What this really requires is a broader patch to add a real 'module' field to the table, rename the current one to 'hook' (or 'base' or some such), and change the logic so that the module declaring a node type is recorded in the table. Please! or look at my simpler patch, which rather requires each node-type module to do it manually.

forngren’s picture

What happens to existing nodes if their node type is deleted?

pwolanin’s picture

typically if the node type goes away, not much of the node is displayed - maybe the title and body. Also, you may not even be able to edit even these if the module is disabled since hook_form is gone. Try - it!

pwolanin’s picture

Status: Needs work » Needs review
StatusFileSize
new3.25 KB

actually, I'm looking at this again now - the fundamental problem is that when we disable a module, hook_form is still in memory. So, maybe we can use $info_array to fix this by checking for . See attached patch - I'm so happy it seems to work!

Actual code changes are ~7 lines - the rest is changed indentation.

pwolanin’s picture

to test, enable then disable a node module like Forum.

without the patch, Forum is still listed ad node/add

you can also go, for example, to admin/content/taxonomy/add/vocabulary
without the patch the content type (forum) is listed even though the module has been disabled

cburschka’s picture

Patch applies cleanly and works as intended for me: After enabling and disabling blog.module, the content type shows up in admin/content/taxonomy/add/vocabulary, but disappears on applying the patch.

(Haven't looked at the code itself)

yched’s picture

Status: Needs review » Reviewed & tested by the community

Works as expected, code is clean.
A word of comment might be useful about the if ($type_object->module != 'node' part ?
Marking as 'needs work' for that, otherwise it looks RTBC to me.

yched’s picture

Status: Reviewed & tested by the community » Needs work

er, "Marking as 'needs work' for that"...

pwolanin’s picture

Status: Needs work » Needs review
StatusFileSize
new3.87 KB

Updated both the doxygen and code comments to improve the explanation.

yched’s picture

Status: Needs review » Reviewed & tested by the community

.. which actually make _node_types_build() function clearer than it was before the patch :-)

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Nothing to add. Great job.

yched’s picture

Version: 6.x-dev » 5.x-dev
Status: Fixed » Patch (to be ported)

This could be worth backporting I guess ?

pwolanin’s picture

yes, a version of this should certainly be backported to 5.x

pwolanin’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new1.81 KB

since the menu part of disabled content types seems to work ok in 5.x as is, this patch is identical to the above minus the node_menu piece.

Again, you can look on a taxonomy vocabulary page, as an example of where a disable node type still appears.

drumm’s picture

Status: Needs review » Fixed

Committed to 5.x.

Anonymous’s picture

Status: Fixed » Closed (fixed)
profix898’s picture

This patch introduced a bug (see http://drupal.org/node/169049). Now all (module-defined) content types, that do not implement hook_form, are listed under node/add. But they are hidden (as expected) in the content type administration pages (admin/content/types).