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

     
     

    Drupal is a registered trademark of Dries Buytaert.