When I set the context detection for group URL to true I got an error on og_get_group function in og_extras_context_handler_url.

I tried to find a way around and what I found is the following modification :

/**
 * Context handler; Get groups from URL.
 */
function og_extras_context_handler_url() {
  $context = array();
  if (arg(0) == 'group' && is_numeric(arg(1))) {
    $context = array('node'=>array(arg(1)));
/*
    $group = og_get_group('group', arg(1));
    if (!empty($group) && !empty($group->nid)) {
      $context = array($group->nid);
    }
*/
  }
  return $context;
}

Now it works. I don`t really know if it`s a bug and if it`s the best way to correct it.
What do you think?

CommentFileSizeAuthor
#3 og_extra.module-issue-1703054.patch717 byteswadmiraal
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Thithi32’s picture

Title: Bug using og_get_group when using Group URL handler (context detection) » Bug when using Group URL handler for context detection
BrightBold’s picture

@Thithi32 — Thanks! You're a lifesaver. I also was getting the error
Fatal error: Call to undefined function og_get_group() in /mysite/sites/all/modules/og_extras/og_extras.module on line 145 when visiting a page where context detection was required. I had poked around in the code looking for the source of the og_get_group() function and couldn't find it anywhere in OG Extras, OG core, or OG Context, so I don't know if it has been removed or if I was just looking in the wrong place. At any rate, your modification solves the problem.

wadmiraal’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Status: Active » Needs review
FileSize
717 bytes

Error is still on dev as well.

The following patch corrects the problem by using the updated OG API. Only use the patch if you're using OG 2 or higher. Also, note this patch only applies to node groups (which is what you would use in 99% of cases anyway).

@maintainers
You should consider creating a 7.x-2.x branch, which would follow the OG core upgrades. This patch could then be applied to that branch. Applying it to your current branch would be a bad idea, as it would break backward compatibility.

BrightBold’s picture

OG Extras module only works with OG 7.x-2.x, so this patch could be committed to the master branch.

joshuautley’s picture

Issue summary: View changes

It could but hasn't. What happened? Any progress?

manasiv’s picture

The patch in #1 works with og extras 7.x-1.2. Thank you!