I recently upgraded my test system to OG 6.x-2.2. With the stock og_forum-6.x-2.2 code, I can display the contents of public forum containers. However, attempts to display forum containers that are only visible to group members resuts in a 'white screen' (the browser View source shows nothing). I can display forum topics using the direct URL.

I verified that the problem is an interaction between og_forum-6.x-2.2 and og-6.x-2.2 by refreshing the test site with og-6.x-2.1, verifying that I can display the forum containers, upgrading to og-6.x-2.2 and re-running the test.

The Drupal log shows no errors. I enabled PHP logging in .htaccess but see nothing. My knowledge of Drupal and PHP is limited, but this suggests to me that OG Forum is simply exiting without generating any HTML. I will try to narrow down the problem by adding trace logic to OG Forum.

Comments

MiniMax’s picture

Same probleme here. Looks like an infinite loop because I get an memory exhausted error, mostyl in includes/menu.inc (lines differ, mostly 315 and 441). Increasing memory size to 256M results in segmentation fault.

[...]
13 0.1037 3049740 og_forum_set_og_group_context_from_tid( ) ../og_forum.module:1369
14 0.1268 4479404 og_set_group_context( ) ../og_forum.module:400
15 0.1269 4479564 menu_get_object( ) ../og.module:728
16 0.1269 4479728 menu_get_item( ) ../menu.inc:703
17 0.1274 4484408 _menu_translate( ) ../menu.inc:318
18 0.1274 4485524 _menu_check_access( ) ../menu.inc:583
19 0.1275 4485960 call_user_func_array ( ) ../menu.inc:454
20 0.1275 4486212 og_forum_access_forum_page( ) ../menu.inc:0
21 0.1275 4486212 og_forum_set_og_group_context_from_tid( ) ../og_forum.module:1369
22 0.1278 4489592 og_set_group_context( ) ../og_forum.module:400
23 0.1278 4489636 menu_get_object( ) ../og.module:728
24 0.1278 4489800 menu_get_item( ) ../menu.inc:703
25 0.1283 4494480 _menu_translate( ) ../menu.inc:318
26 0.1283 4495596 _menu_check_access( ) ../menu.inc:583
27 0.1284 4496032 call_user_func_array ( ) ../menu.inc:454
28 0.1284 4496284 og_forum_access_forum_page( ) ../menu.inc:0
[...]
This is repeated until memory exhausted...

Quick and Dirty fix: Remove in file og.module in function og_set_group_context the following lines:

    $current_node = menu_get_object();
    if (!$current_node || (!og_is_group_type($current_node->type) && $current_node->language == $node->og_language)) {
      og_set_language($node);
    }
nhoeller’s picture

@MiniMax, I have verified that your fix works. For my own education, how did you get the call trace and also how did you find what needed to be changed in og.module?

I inserted trace code into og_forum.module. Prior to the OG upgrade:

  • the function og_forum_access_forum_page was called with the tid of the private forum container (232)
  • the function og_forum_set_og_group_context_from_tid was called and identified the gid of the associated group node (119)
  • the function og_forum_access_forum_page was called with the tid of the group node (119) and returned the value TRUE
  • the function og_forum_topic_redirect was called with the tid of the private forum container (232)

After the OG upgrade:

  • the function og_forum_access_forum_page was called with the tid of the private forum container (232)
  • the function og_forum_set_og_group_context_from_tid was called and identified the gid of the associated group node (119)
  • the function og_forum_access_forum_page was called with the tid of the private forum container (232)
  • we end up in a recursive loop

Further tracing indicated that control never returns from og_forum_set_og_group_context_from_tid back to og_forum_access_forum_page, suggesting that the function og_set_group_context is causing the recursive loop. This is consistent with the fix you posted.

I assume that og_forum has a hook somewhere that is causing the recursive loop. Any ideas on how to cleanly fix this problem?
Thanks, Norbert

izmeez’s picture

Project: OG Forum » Organic Groups
Version: master » 6.x-2.2
Component: Code » og.module

I noticed this issue even though I'm not using OG Forums.

The fix in comment#1 is essentially reversing the og.module 2010-12-21 commit, http://drupalcode.org/project/og.git/commit/3d9b2343b347977a26722e180efa...

I'm changing the project to the og.module for further comment and patch where needed.

jvieille’s picture

sub

Grayside’s picture

Project: Organic Groups » OG Forum
Version: 6.x-2.2 » 6.x-2.x-dev
Component: og.module » Code

Do not set group context in an access handler. Set it in hook_init() before OG acts.

nhoeller’s picture

@Grayside, at the risk of revealing my paltry knowledge of Drupal, are you suggesting that OG Forum should set the group context earlier via a hook_init() call, rather than from the og_forum_access_forum_page function? As I read the OG Forum code, the group context depends on the specific forum container being displayed.

Grayside’s picture

In my code review, it appeared the context was being set by the access callback. This is dangerous, because anything that checks access to that page will end up trying to set the group context.

Not only does that mean use of basic API functions like menu_get_object() becomes recursive, it also means that simple information retrieval of access information can result in changing the behavior of the page load.

nhoeller’s picture

The culprit appears to be the call to og_set_group_context from og_forum_access_forum_page, which is defined here:

function og_forum_menu_alter(&$callbacks) {
  $callbacks['forum']['access callback'] = 'og_forum_access_forum_page';
  $callbacks['forum']['access arguments'] = array(1);
  $callbacks['forum']['page callback'] = 'og_forum_topic_redirect';

A little knowledge is a very dangerous thing, but it did not seem that og_forum_access_forum_page referenced any group context information. I removed the call to og_forum_set_og_group_context_from_tid and restored the original 6.x-2.2 og.module - so far, everything seems to be working. I have only done very minimal testing:

  • visitor
  • logged in user who is not a member of any group with private forums
  • logged in user who is a member of a group with private forums

A review by someone who actually knows what they are doing would be advisable (:-).

jvieille’s picture

Could you explain a little bit what you have done exactly to make it work? Which file, which function (or line number...)

I tried to comment out
og_forum_set_og_group_context_from_tid($result->tid);
in
in function og_forum_form_alter(&$form, &$form_state, $form_id) {

But it does not help.

Thanks

nhoeller’s picture

@jvieille, the change is in og_forum_access_forum_page:

function og_forum_access_forum_page($tid = 0) {
  if (!user_access('access content')) {
    return FALSE;
  }
  global $user;

  if ($tid != 0) {
// resolve recursive loop after upgrade to og-6.x-2.2
//  og_forum_set_og_group_context_from_tid($tid);
    $gid = og_forum_gid_from_tid($tid);
    if ($gid) {
MiniMax’s picture

StatusFileSize
new708 bytes

@nhoeller: The stack trace is shown in the browser after installing the php plugin xdebug. On Debian you just have to install php5-xdebug.

Your modification in #10 seems to be the better solution which works for me, too. Attached is a corresponding patch.

nhoeller’s picture

@MiniMax, thanks for the tip on xdebug! I got it installed this morning and now have a massive trace of a 'forum' call.

jvieille’s picture

It works for me, using the latest published OG forum

Media Crumb’s picture

Odd thing with this patch (or it could have been before and I didnt notice.) Now when visiting a groups page and clicking on the forum tab all I see is:

Array
New posts
No new posts
Hot topic with new posts
Hot topic without new posts
Sticky topic
Locked topic

The forum itself is gone. I'm assuming it has something to do with the word "Array" being posted and not the actual information. It also seems like the menu @ /og_forum/manage/(group ID) no longer has some items. I can't set to private or create new forum from this area. Anyone else have these 2 issues?

nhoeller’s picture

@Media Crumb, I am not seeing these symptoms but there does seem to be a problem. If I go to <domain>/og/my, I see a list of groups of which I am a member. Clicking on a group brings up the OG document for that group with View, By Term and Forums tabs at the top. View shows me recent activity, By Term shows me forum topics by taxonomy tags, but Forums only shows the forum topics within one of several forums.

I have not explored this path in the past so cannot tell if or when it last worked. I go directly to <domain>/forum.

Do you have the resources to revert back to OG 6.x-2.1 to see if the problem is introduced by the the OG upgrade or the patch to OG Forum? I am tied up trying to learn how Drupal hooks, OG Forum and xdebug work (:-).

Media Crumb’s picture

I'm using it on a production site so its going to be hard to do ATM. It stinks because I didn't catch it before launch. What is worse is it looks like anyone can view the private forums so long as they have the direct link to the post. I thought this was fixed, but I guess that isn't the same issue as I thought.

Just out of interest, what options do you have in your block for menu options. ATM I have:

Group forums
Manage group forums
68 members
Manager: (Manager Name)
Invite members

Not surprisingly I have the same options as you but View, By Term and Forums tabs all turn blank when clicked on. The only difference is that Forums simply spits our "Array"

Sadly I can't seem to find anyone else with this issue and I'm stuck with a live production site with bad links and completely public posts! :(

nhoeller’s picture

@Media Crumb, I just tested on my production site (OG 6.x-2.2, OG Forum 6.x-2.2 with patch) - a visitor or registered user cannot view a private forum even if they know the URL. I recall OG Forum exposed the names of private forums through the taxonomy structure, something thePanz+Lirantal patch were supposed to fix. There is a thread starting around http://drupal.org/node/1055424#comment-4326762 that suggests the node_access table can get corrupted. I was never able to reproduce this problem but suspect it has something to do with multiple contributed modules trying to set node permissions for a forum topic.

In terms of the group block used to manage group membership, I have

  • title of the group
  • a bunch of Create content links
  • 'Group forums' (only shows forum topics associated with one of my forums)
  • 'Manage group forums' (shows a list of forums associated with the group)
  • 'Invite friend'
  • 'nn members'
  • 'Manager:' (group manager)
  • 'My membership'

When I clicked on 'Manage group forums', I noticed one orphan forum (I recall having problems with it in the past). Two of the forums associated with the group had 'Make private' links, which is a bit disconcerting. The rest had 'Make public' links. On further checking, it looks like the two 'public' forums were actually private but contained forum topics that had been marked as public. A visitor or a registered user who is not part of the group can see the forum and the public forum topics, but nothing else. All other forums and forum topics result in 'Access Denied'.

I am not sure what to suggest - my suspicion is either an incompatibility with another contributed modules or issues with the OG Forum/OG configuration.

Media Crumb’s picture

Thanks so much for the feed back nhoeller you have been fantastic! Is there any way I can get your OGforum folder just so I can run the diffs to see if there are any glarring issues? I'm going to check with nodeaccess to see if I have something scew'ed up in there as well. Thanks again!

oriol_e9g’s picture

Assigned: Unassigned » oriol_e9g

I have the same problem but we need to a apply a more extense fix. Patch in progres... .)

oriol_e9g’s picture

Assigned: oriol_e9g » Unassigned
StatusFileSize
new717 bytes

Ops! Not true, the same patch in # 10 works. Attached our patch with comment reference to this issue.

vegantriathlete’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)