Forum overview stopped working

Last modified: March 5, 2008 - 03:28

Following a problem of the forum overview stopped working (missing vocab after disabling, deleting, re-enabling the module as described here

When the forum module is first enabled, it creates a vocabulary of its own (called Forum) where it stores half its structure.
If for any reason this vocabulary is deleted (like you decide you don't want forums yet, or you're working on an unstable development site) re-enabling the module will not correctly re-create the needed vocab again

Thus, you end up with only half a working forum. It seems you can post topics, but the indexing and overview pages are a bit scrambled, and don't list anything useful.

(Just remaking a new 'Forum' vocabulary manually will not work.)

The Fix

... is to tell the forum module to forget its old invalid vocabulary id and make a new one.

Short answer is this code needs to run:

<?php
variable_del
('forum_nav_vocabulary');
?>

I use the devel.module, which provides a console where I popped this line, and a variable viewer which showed me what happened, but another quick way is:

  • Create new node (don't save)
  • Set content to php code. Disable wysiwyg if needed
  • Paste the above in the body
  • Preview
    • the php code will execute, although you won't see anything yet.
    • discard the node, don't need to save it.
  • visit admin/forums
    • this triggers the forum code to check if its parameters are correct.
    • they are not so it will create the Forum vocab as needed
  • continue, create a new forum or container. The pages should work again as they are supposed to.

From comments

You may need to perform a few more steps for Drupal 5. At least I did when I disabled and then enabled my forum in Drupal 5.2
1) Follow step one from above
2) Then visit the /admin/content/forum URL as described above
3) Then preview the following php code in the same manner described above

<?php
$vid
= _forum_get_vid();
print
'This is the result from _forum_get_vid() ' . $vid;
$vid = variable_get('forum_nav_vocabulary', '');
print
'<br>This is the result from variable_get(forum_nav_vocabulary, ) ' . $vid;
?>

You should get a number. Use that number for the next step. For instance if your number was a 1 then use 1 below ...
4) On table vocabulary_node_types I added the row vid=1 type=forum

This brought back all my forums and I did not have to delete any posts, categories, forums, or database tables.

Another thing that can happen is the forum vocabulary forgets the forum node type is part of it. It's impossible to fix this through the UI because the checkbox is force checked and greyed out. So you can do it in the database:

INSERT INTO `YOUR_DATA_BASE_NAME`.`vocabulary_node_types` (`vid`, `type`) VALUES ('1', 'forum');

Replace YOUR_DATA_BASE_NAME with the name of your database and '1' with the ID of your forum vocabulary.

Obviously back up your database before you do anything

.

Michelle - November 11, 2008 - 16:31

I don't have time to clean up the page right now but I just went thru this to fix someone's site and step 4 should be:

<?php
db_query
("INSERT INTO {vocabulary_node_types} (vid, type) VALUES ('1', 'forum')");
?>

Those quotes on vid & type give a syntax error that took the folks on IRC to figure out for me.

Michelle

--------------------------------------
See my Drupal articles and tutorials or come check out life in the Coulee Region.

Having this problem

DreamersDelight - November 19, 2008 - 15:42

Hi,

I have a couple of questions about this fix.
How does one add a node?
Is this node a new page? If it's a new page, I can't enable php code anywhere, could you elaborate on this somewhat?
Could you also elaborate on the devel.module, I can't find the console to which you refer?
I think I'm not alone in saying that this page isn't really clear to a drupal newbie like myself, but it's a problem I'm shure newbies will encounter and will set them off drupal after not finding a quick sollution.

Thanks in advance.

Php activation

nonnymouse - December 25, 2008 - 12:10

Its worth noting that to activate php you need to tick the checkbox against

admin/modules/PHP filter 6.8 Allows embedded PHP code/snippets to be evaluated.

Delete all forums and start again

nonnymouse - December 25, 2008 - 12:43

Then there is also this solution if you have just started..

http://drupal.org/node/169078

Could this affect the D6

chrism2671 - May 20, 2009 - 19:37

Could this affect the D6 branch as well?

D6 users read this:

dddave - July 19, 2009 - 11:30

If you ran into this scenario as and use i18 check that the content selection mode at admin/settings/language/i18n/configure reflects the language settings of your forum posts and vocabulary. If you set your system to "Current Language" you won't see any posts when they are created language neutral.

If the problem still exists or if you don't use i18 check the following:

1) You have a forum vocabulary
2) That forum vocabulary is applied to all node types you want to be in your forum
3) In the variables table, forum_nav_vocabulary matches #1
4) The forum table contains all the nodes you expect to find in the forum
5) The tids that go with the nodes in #4 are tids that are part of the vocabulary in #1
6) There are no node access modules that may be hiding stuff from view

If these checks don't help try this ressource by cog.rusty: http://drupal.org/node/317202#comment-1044468

Still no good? Nuke the whole forums stuff and start again (or find another solution - perhaps the original stuff on this handbook page).

cog.rusty comes to the rescue again:
http://drupal.org/node/169078#comment-263873

As a D6 user you won't be able to perform step 3 and shouldn't need 6 and 7 (but check them anyways). Be sure you never renamed the vocabulary because in this case I noticed that the wrong name was given to the freshly created vocab. So I had to rename it back to "Forums" and do the clean up again. This worked for me and luckily it did not affect a live site with 1000s of topics and comments.

This did not work for me

jvieille - August 23, 2009 - 08:15

This part
...
visit admin/forums
this triggers the forum code to check if its parameters are correct.
they are not so it will create the Forum vocab as needed
continue, create a new forum or container. The pages should work again as they are supposed to.

did not work
- there is no such a page admin/forums. I suppose it is admin/content/forum
- At this point, instead of missing only the last posts, all forums disapeared for ever and never showed up again.

So I followed the advices and perform the checks in http://drupal.org/node/317202#comment-1044468
It appeared that the variable forum_nav_vocabulary was not recreated as expected.
I recreated manually the variable in the data base, but still nothing.

I disabled and re-enabled TAC Lite, being asked to rebuild permissions (I guess it would have sufficed to run this procedure without disabling TAC Lite) : I got everything back, new topics begin to appear again.

However, the latest created topics before the problem was solved where still missing.

I cloned them to get them back in their respective forum.

JV

Check this out ...

ro_x_taz - October 3, 2009 - 21:15

Something that worked for me : http://drupal.org/node/509540#comment-2111240

 
 

Drupal is a registered trademark of Dries Buytaert.