I have organic groups 5x.7.3 and have been getting a lot of the following errors occurring on all kinds of non group nodes.

user warning: Duplicate entry 251-0-og_public; for key 1
query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (251, etc.

I understand that in og_user_roles_node_access_records() you endeavour to catch all nodes that og_access_node_access_records() misses. In the latter is the condition: elseif (is_array($node->og_groups)) which you counter in og_user_roles_node_access_records() with: (is_array($node->og_groups) && count($node->og_groups) === 0). It is possible for a node to accept both conditions (be and array and have no contents) therefore I think a lot of my nodes are collecting two versions of the og_public grant.

I am changing the og_user_roles_node_access_records() condition from

   if (og_is_omitted_type($node->type) || (is_array($node->og_groups) && count($node->og_groups) === 0) || (!is_array($node->og_groups) && !og_is_group_type($node->type))) {
      $grants[] = array (
        'realm' => 'og_public',
        'gid' => 0,
        'grant_view' => 1,
        'grant_update' => 0,
        'grant_delete' => 0 );
    }
    

to

  if (og_is_omitted_type($node->type) || (!is_array($node->og_groups)) || (!is_array($node->og_groups) && !og_is_group_type($node->type))) {
      $grants[] = array (
        'realm' => 'og_public',
        'gid' => 0,
        'grant_view' => 1,
        'grant_update' => 0,
        'grant_delete' => 0 );
    }

which should stop this duplicate entry warning.

Comments

NewZeal’s picture

Update: The above still produced errors on group home pages so changed the condition to:

  if (og_is_omitted_type($node->type) || (!is_array($node->og_groups) && !og_is_group_type($node->type))) {
somebodysysop’s picture

Status: Active » Postponed
sun’s picture

Status: Postponed » Closed (won't fix)

With the rise of the rewritten OGUR 4.x for Drupal 6, in which many unrelated features of OGUR were removed, and nearing a release of Drupal 7, I'm closing down old issues.