Forum taxonomy menu not populated when creating new node

kentr - September 17, 2009 - 16:33
Project:OG Forum
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:paulbooker
Status:needs review
Description

(continued from http://drupal.org/node/555964)

Description:
In certain circumstances when creating new topics, the "Forum:" menu is not populated with choices. Since that field is required, this issue prevents the user from being able to create the node.

Repeatable:
Always

Steps to repeat:
Click the "Create new Forum topic" link (specifically, it's the path node/add/forum that causes the problem).

Details:
The issue appears to be in og_forum_db_rewrite_sql() (og_forum.module), when $_GET['qids'] is unset.

Some proposed solutions are in the previous thread.

#1

kentr - September 17, 2009 - 20:34
Title:Forum taxonomy menu not populated» Forum taxonomy menu not populated when creating new node

Specific comments referencing this issue in the previous thread:

http://drupal.org/node/555964#comment-2041694
http://drupal.org/node/555964#comment-2048260
http://drupal.org/node/555964#comment-2050744
http://drupal.org/node/555964#comment-2051124

#2

kentr - September 17, 2009 - 20:01

Here's what I've tried with the query.

Change these lines:

og_forum.module ~line 416

<?php
   
if (arg(0) == 'node' && arg(1) == 'add' && arg(2) == 'forum' && empty($_GET['gids'])) {
     
$return['join'] = "LEFT JOIN {og_term} ogt ON t.tid = ogt.tid";
     
$return['where'] = "ogt.nid IS NULL";
?>

to:

<?php
   
if (arg(0) == 'node' && arg(1) == 'add' && arg(2) == 'forum' && empty($_GET['gids'])) {
     
$return['join'] = "LEFT JOIN {og_term} ogt ON t.tid = ogt.tid LEFT JOIN {og_uid} u  on u.nid = ogt.nid";
     
$return['where'] = "(ogt.nid IS NULL OR (ogt.nid = u.nid AND u.uid = {$user->uid} )) ";
?>

Seems to be working with User 1 and an Authenticated User (typical permissions), under these conditions:

  • User 1 is a member of all groups
  • Authenticated User is only a member of 1 group
  • All forums are in a group (container)

Needs to be tested with:

  • The existence of forums not in a group (where ogt.nid is NULL) Tested: OK
  • Perhaps other forum publicity settings of which I'm not aware?

#3

kentr - September 17, 2009 - 20:12

Here's a patch for the above.

AttachmentSize
og_forum-580452-3.patch 800 bytes

#4

kentr - September 17, 2009 - 20:33
Status:active» needs review

#5

paulbooker - September 18, 2009 - 09:21

I have a single site wide forum and can see that when i go /node/add/forum

AttachmentSize
Picture 1.png 133.26 KB

#6

kentr - September 18, 2009 - 16:54

@#5

Sorry, I'm confused. Does that mean your test case is working as intended?

I dug into publicity a little more. Does the publicity of the forum need to be considered at this point the code (og_forum_db_rewrite_sql()), or is that handled somewhere else? Note: publicity issues appear to be related to http://drupal.org/node/579734

If they need to be considered in og_forum_db_rewrite_sql(), need info on the status codes.

Questions:

  • Is testing against the 'public' column in `og_term` enough, or are there cases where that column value is overridden at runtime by automated publicity or whatever?
  • If testing against the 'public' column is enough, is any value > 0 considered to be public? (i.e. will it suffice to add ogt.public > 0 somewhere in the query)?

#7

capellic - September 23, 2009 - 17:46

Thanks for the patch! It's working for my "authenticated user" who belongs to the private group that has this forum.

#8

paulbooker - September 29, 2009 - 16:50
Assigned to:Anonymous» paulbooker

Thanks for all your help here kentr

I'll have a look at this tomorrow as a priority.

Best, Paul

#9

paulbooker - September 30, 2009 - 16:02

"In certain circumstances when creating new topics, the "Forum:" menu is not populated with choices. Since that field is required, this issue prevents the user from being able to create the node."

Would you mind clarifying exactly what the circumstances were so that i can repeat the problem
and investigate more efficiently.

If there are no site wide forums defined then it is true that you will not be able to make a post
on /node/add/forum (not sure if that helps)

#10

kentr - October 8, 2009 - 04:30

Paul,

Sorry it wasn't clear...

One example based on my setup (from memory. I can't repeat b/c I'm using the patch above):

Steps to repeat

  1. Set up the containers & forums so that you can view a list of forums without being "inside" a group container.
    Example:
    • Two containers, each at the root level, each belonging to a different group.
    • Several forums in each of the containers mentioned above.
    • No forums at root level.
  2. Create a new node:
    • When viewing the top level of the forums, click the Post new Forum topic link at the top of the forum list. More specifically, when not "inside" a group - for my site, this is the default module page, at /forum
    • From any other page on the site, in the Navigation menu (or Administration menu), click Create content -> Forum topic
    • By any other mechanism that uses the simple path node/add/forum or node/add/forum/nn without gids in the path.

Update:

I just noticed this:

If there are no site wide forums defined then it is true that you will not be able to make a post
on /node/add/forum (not sure if that helps)

Ok, didn't know you were aware of this. This is the bug, IMO.

Expected behavior:

Clicking a link entitled "Post new Forum topic" that leads to node/add/forum will allow user to successfully create a forum topic.

Proposed solution:

  • Modify SQL query for forum list (in og_forum_db_rewrite_sql()) so that in cases where $_GET['qids'] is unset, the query returns all forums for which user has permission to post, regardless of whether there are site-wide forums defined. That's what patch #3 is attempting to accomplish.
  • Since this could get unwieldy when there are many forums, possibly add a configuration setting to optionally declare a default forum or container to display in the taxonomy SELECT in the node edit form for this case.

#11

kentr - October 3, 2009 - 19:14

Updated previous comment for clarity & details.

#12

kentr - October 8, 2009 - 04:23

Updated #10 to more succinctly state proposed solution.

#13

sebzur - October 22, 2009 - 18:55

Subscribing.

#14

chriskip - October 23, 2009 - 07:12

Subscribed

#15

tobiberlin - October 27, 2009 - 08:24

subscribing - for me this issue appeared with the last update

#16

benjamin_dk - November 13, 2009 - 08:36

subscribing - I am experiencing the same with version 6.x-2.0. I can select forum in the OG forum, but not in any other. I tried the patch, but to no avail. I got no error reports from using the patch.

Edit: I closed the new issue I made for the 6.x.-2.0 version, and post the information here instead (on suggestion from kentr.)

Description

Repeatable: Always

Steps to repeat:

  1. download and unzip og_forum from  http://ftp.drupal.org/files/projects/og_forum-6.x-2.0.tar.gz into the modules folder.
  2. Setup forum structure and Organic Forum settings as described below
  3. goto URL node/add/forum

Expected results:

The forum dropdown list populated with the forums the user have access to post to.

Actual results:

The forum dropdown list is empty ("please select" being the only entry). It is not possible to add new forum topic.

Further details:

After updating OG forum to the latest version (6.x.2.0) it is no longer possible to add new forum topics via the URL node/add/forum, since the forum taxonomy dropdown is not populated , neither as anonymous, authenticated user or user 1.

If I make forum topics as a group member into the OG forum -  node/add/forum/83?gids[]=147 - the dropdown is populated with the OG forums. 

If I deactivete OG forum everything works as it should (except of course now the former OG forum appears in the forum list for all users).

We have the following forum structure - admin/content/forum:

  • Public forum container 1
    • Public forum a
    • Public forum b
  • Public forum container 2
    • Public forum c
    • Public forum d
    • ...
  • OG Forum container
    • OG forum a
    • OG forum b
    • ...

Settings:

Organic groups access configuration admin/og/og_access >

  • Visibility of posts : Visible only within the targeted groups.

Private groups

  • New group home pages and default audience are always private.

OG forum admin/og/og_forum > group forum container >

  • Would you like all group forums to be placed in the same container? : checked
  • Forum publicity administration: nothing checked

Content type forum - admin/content/node-type/forum >

  • Organic groups settings: May not be posted into a group (I also tried "Standard group post (typically only author may edit)").

Hope someone can clarify what has gone wrong. The error happened after a lot of modules being updated + Drupal core updated to 6.14 - so other things might play a role!

#17

kentr - November 12, 2009 - 23:43

For cases when the patch didn't work: any errors, or did the patch just not apply?

If it were me, I'd appreciate having the threads combined, even though they're different versions. Easier to keep track of, and many people are already subscribed to this thread.

#18

kentr - November 13, 2009 - 05:12
Version:6.x-2.0-rc5» 6.x-2.x-dev

Here's a new patch against 6.x-2.x-dev, 2009-Nov-11.

Please also look for issues with non-public forums showing up in the dropdown when they shouldn't.

AttachmentSize
og_forum-580452-18.patch 695 bytes

#19

benjamin_dk - November 13, 2009 - 10:22

Yesterday I un-installed the old version of OG forum completely before I tried with the 6.x-2.0 version. This brought back the taxonomy in the dropdown - but suddenly the former hidden og forum (minus threads/nodes) was also visible to non-members. I tried to fiddle around to make it work, but couldn't.

Today I did the same with the 6.x-2.x-dev, 2009-Nov-11 version and the og_forum-580452-18.patch. The result was the same - the dropdown populated, but the og forum visible to non-members at /forum. After I set the group forum container to the "old" one at OG forum admin/og/og_forum > group forum container >, this container and its forums disappeared from the dropdown menu - both for non-members AND members. It is as if the old og forums (and/or container?) needs to be reconnected to the group/defined as og forums once again?

I thought about choosing the "retroactively update old groups" option, but I am not sure this will help me out, since I already have my forums.

#20

kentr - November 14, 2009 - 01:08

I can possibly fix the issue with hidden forums showing up because of the patch, but I need more information on hidden forums since I'm not familiar with them.

@benjamin_dk (or someone else):

What are the conditions under which a forum is hidden? And if possible: how is that info stored in the database (what table / column)?

#21

benjamin_dk - November 16, 2009 - 10:10

As far as I can see from og_forum.module, the conditions that control the visibility of a forum has to do with the og_forum_is_public-function (line 1294). Here a row from the og_term table is tested for content and the status of the public-field.

When I look in my DB I can see, that I have no content in my og_term-table! I guess this is where my old og-forum ought to be?

Here are some more values from the DB regarding my old og-group that might be relevant:

Organic Group-table "og":

og_selective: 1
...
...
og_register: 1
og_directory: 1
og_private: 0

#22

unknownguy - November 18, 2009 - 15:26

Patch #18 worked for me, subscribing.

#23

paulbooker - November 27, 2009 - 13:30

Currently if you go to /node/add/forum you will only see the public forum or no forums if you have no public forums.

This approach looks to allow you go to /node/add/forum and see both public forums & group forums for groups the user is subscribed to. Is this what is being called for here? (Sorry i don't have the time to go through the whole thread right now)

Best,
Paul Booker

#24

kentr - November 30, 2009 - 19:08

This approach looks to allow you go to /node/add/forum and see both public forums & group forums for groups the user is subscribed to. Is this what is being called for here?

Yes.

#18 adds a join to group membership tables to accomplish this.

According to #19, my patch had an undesirable side-effect. Haven't had time to look into it.

#25

kentr - November 30, 2009 - 19:31

This brought back the taxonomy in the dropdown - but suddenly the former hidden og forum (minus threads/nodes) was also visible to non-members

Making sure I understand: the formerly hidden forums suddenly appeared in the forum listing at /forum, not in the taxonomy dropdown on the node edit form, correct?

In other words, after the patch, the taxonomy menu was working as you expected / desired, and the main forum view page was not?

After I set the group forum container to the "old" one at OG forum admin/og/og_forum > group forum container >, this container and its forums disappeared from the dropdown menu - both for non-members AND members. It is as if the old og forums (and/or container?) needs to be reconnected to the group/defined as og forums once again?

Please open a new issue for this, since this appears to a separate issue (sounds like it the empty og_term table is part of this problem).

#26

kentr - December 1, 2009 - 01:07

but suddenly the former hidden og forum (minus threads/nodes) was also visible to non-members.

#19: I can't recreate this problem. How are your private forums set up?

 
 

Drupal is a registered trademark of Dries Buytaert.