Revision 1.407, #20295: Allow forum topics to be custom node types removed the {forum} table and turned
function forum_load($node) {
$forum = db_fetch_object(db_query('SELECT * FROM {forum} WHERE vid = %d', $node->vid));
return $forum;
}
into
function forum_load($node) {
$forum = db_fetch_object(db_query('SELECT * FROM {term_node} WHERE vid = %d', $node->vid));
return $forum;
}
This sets $node->tid to the first tid that comes along, which is not necessarily the tid from the forum vocabulary, leading to strangeness as in #410930: forum access is not working if another taxonomy is assigned to forum posts.
chx put the {forum} table back in with 1.418 and explained it well in #172643-4: Beta breaker: Forum: Leave shadow copy doesn't leave shadow copy., but he forgot to roll back forum_load().
The attached patch fixes the forum nodes. Weighing the simplicity of the patch against its usefulness, I'm marking this critical.
This issue is not present in D7.
Comment | File | Size | Author |
---|---|---|---|
#8 | forum_module-forum_nodeapi.D6.patch | 782 bytes | jeremiah.snapp |
forum_module-forum_load.D6.patch | 647 bytes | salvis | |
Comments
Comment #1
OHGE CreditAttribution: OHGE commentedfixed some troubles I had :)
Comment #2
Damien Tournoud CreditAttribution: Damien Tournoud commented*Sigh*
First D7, then D6.
Comment #3
salvis*Sigh* — as I wrote above, this is not an issue for D7.
forum_load() is gone from D7.
$node->tid
is set in forum_node_view() with...... so it gets the correct tid.
Comment #4
salvisWhat can we do to get this obvious bug fixed?
Comment #5
sunThis indeed seems to be fixed in D7 already: http://api.drupal.org/api/function/forum_node_load/7
http://api.drupal.org/api/function/forum_nodeapi/6 already uses {forum}, too.
Only http://api.drupal.org/api/function/forum_load/6 seems to be still using the {term_node} table.
Comment #6
Gábor HojtsyThanks, committed.
Comment #8
jeremiah.snapp CreditAttribution: jeremiah.snapp commentedThe attached patch modifies the existing sql statement in the 'presave' case in forum_nodeapi to use {forum} instead of {term_node}.
I'm not sure but I wonder why the 'presave' case in forum_nodeapi can't use the more simple sql statement the forum_load function uses.
The current method of joining tables seems unnecessary to me but I might be missing something.
If others decide the more simple sql query should be used then we may want to consider porting this forward to D7's forum_node_presave function.
Either way it should be using the {forum} table instead of {term_node}.
This issue is not present in D7.
Comment #9
sunLooks to be the same change as in the original patch, just a different query.
Comment #10
jeremiah.snapp CreditAttribution: jeremiah.snapp commentedThis is for the 'presave' case in forum_nodeapi. The original patch was for forum_load.
Comment #11
salvisIn forum_load() we already know which revision id to get. The code in 'presave' makes sure it gets the latest vid. We might be editing an older revision (which had a different tid), but when saving, we want to replace the latest revision (i.e. the tid that goes with the latest vid). So, no, it cannot be simplified.
The forum_nodeapi() code was newly introduced in the same revision 1.407 as the original bug of this thread and fixed in 1.418 to its present state, and I agree that it's the same bug.
+1 for the patch in #8.
Comment #12
salvisLet's fix this. It can cause nasty errors when trying to move a forum topic from one forum into another. The "shadow copy" left behind may end up with a tid that is not a forum, if the forum topics have additional vocabularies!
It's difficult to construct a test for this that would reliably fail if it were broken. The reason is that the current code retrieves the tid from {term_node}. If we're lucky, the first (and only retrieved row) happens to actually give the forum_tid, but it might also give the tid from another vocabulary.
The order of the records in {term_node} is not defined and impossible to control in a DB-independent way, so we cannot create a test that reliably returns the bad tid.
Comment #13
jeremiah.snapp CreditAttribution: jeremiah.snapp commented@salvis Thanks for supporting this. This is the first patch I've submitted to core. Is it likely to be difficult getting it approved. Anything I can do to help?
Comment #14
salvisHaving your patch tested by the testbot would help a lot. I'm not sure why the test bot is ignoring it.
Try re-uploading it and remove ".D6" from the filename.
Comment #15
webchickTestbot doesn't review D6 patches. We didn't get a testing framework in core until D7, so that's by design.
Comment #16
salvisI thought so, too, but then I saw
#345080-24: term_node table is empty after upgrading from Drupal 5 to 6 and
#746440-4: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list, for example.
Those are D6 patches and according to the test report they were tested against D6.
There are lots of others, but they all have one thing in common: they all FAILED. I haven't found any D6 patch that PASSED, only Ignored and FAILED ones. Strange...
Comment #17
Gábor HojtsyLooks like a simple change similar to the previous patch. Thanks, committed.