I'm confused about the purpose of the {forum} table? In D5, it used to store vids, which {term_node} didn't, but now that {term_node} has vids, too, it seems like {forum} is just a (redundant!) subset of {term_node}.

Does the {forum} table serve any useful purpose? Can it ever contain any rows that are not in {term_node}?

Comments

nevets’s picture

I suspect the issue is that it is only a subset. Since you can use the forum vocabulary for other content types {term_node} may contain entries for content that are not part of the forum.

salvis’s picture

From the Drupal 6 release announcement:

Forum improvements
Include polls, quiz forms or any other type of content in forums.

I understand this to mean that any node (of any content type that supports the Forum vocabulary) that has a term of the Forum vocabulary assigned, is in that forum.

IOW, any {term_node} record with a tid out of the Forum vocabulary would also be in the {forum} table.

Am I missing something?

nevets’s picture

I took it to mean you can include other content types in the forums but that you could also just use the same vocabulary without putting the content in the forum.

salvis’s picture

I've created an event (not forum topic) and assigned a forum term, and the event shows up in the forum.

How would you assign a forum term without having the node show up in the forum?

salvis’s picture

There's a query in forum_get_topics() that goes like this:

SELECT n.nid, r.tid, n.title, n.type, n.sticky, u.name, u.uid, n.created AS timestamp, n.comment AS comment_mode, l.last_comment_timestamp, IF(l.last_comment_uid != 0, cu.name, l.last_comment_name) AS last_comment_name, l.last_comment_uid, l.comment_count AS num_comments, f.tid AS forum_tid 
  FROM {node_comment_statistics} l 
    INNER JOIN {node} n ON n.nid = l.nid 
    INNER JOIN {users} cu ON l.last_comment_uid = cu.uid 
    INNER JOIN {term_node} r ON n.vid = r.vid 
    INNER JOIN {users} u ON n.uid = u.uid 
    INNER JOIN {forum} f ON n.vid = f.vid 
  WHERE n.status = 1 AND r.tid = %d

If n.vid = r.vid = f.vid, shouldn't f.tid be the same as r.tid? Why join with the {forum} table?

salvis’s picture

Status: Active » Fixed

I got my answer: {forum} has only one (nid/vid/tid) record per vid, namely the one referring to THE forum which contains the node. If a forum topic is moved from tid1 to tid2 and the user chooses to leave a shadow copy behind, then {forum} will have (nid/vid/tid2), and {term_node} will have both (nid/vid/tid1) and (nid/vid/tid2).

In the query above the JOIN with {term_node} and the r.tid = %d condition gives us not just the nodes in %d but also those that have shadows in %d, and the JOIN with {forum} gives us f.tid AS forum_tid, so we know whether we have a forum post or just a shadow.

keith.smith’s picture

Status: Fixed » Closed (works as designed)
akwala’s picture

subscribe