I started getting this after my latest D7 uodate:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry og_access:node for key PRIMARY INSERT INTO {node_access} (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5), (:db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11); Array ( [:db_insert_placeholder_0] => 1553 [:db_insert_placeholder_1] => og_access:node [:db_insert_placeholder_2] => 1553 [:db_insert_placeholder_3] => 1 [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => 0 [:db_insert_placeholder_6] => 1553 [:db_insert_placeholder_7] => og_access:node [:db_insert_placeholder_8] => 1553 [:db_insert_placeholder_9] => 1 [:db_insert_placeholder_10] => 0 [:db_insert_placeholder_11] => 0 ) in node_access_write_grants() (line 3557 of D:\xampp\htdocs\php\extranet\modules\node\node.module).

Tracing & debugging it, I would modify og_access.module around lines 123 to be:

case OG_CONTENT_ACCESS_PRIVATE:
$tmpArray = og_get_entity_groups('node', $node);
$key = array_search($node->nid, $tmpArray['node']); // remove nid if had been added previously
if (false !== $key)
unset($tmpArray['node'][$key]);
$gids = array_merge_recursive($gids, $tmpArray);
break;

Otherwise $gids ends up having two identical elements, thus the DB insert duplicate. You guys are the OG gurus: opinion?

thx

Sebastien

CommentFileSizeAuthor
#5 og_access.module.diff476 bytesabautu
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

slapierre’s picture

Issue summary: View changes
arunverma’s picture

Hi

Having same issue, when try to rebuild permission.

Any idea, please.

thx
Arun

shushu’s picture

Status: Active » Postponed (maintainer needs more info)

Can you please elaborate ?
Please describe the scenario that creates this situation, so we will be able to reproduce.

mikedoth’s picture

Version: 7.x-2.7 » 7.x-2.x-dev

I'm having this issue in 7.30 and were also getting them in 7.29 as well. Recently we found that after disabling then enabling Organic Groups Access Control we get PDO errors (below).

Duplicate entry '4-4-og_access:node' for key 'PRIMARY'...

Has anyone made any headway on this?

abautu’s picture

FileSize
476 bytes

I have this issue in project with private subgroups. Some users are admins to parent groups and children subgroups and og_access tries to include node_access records for same content due to both contexts (ie. explicit administrator of child + inherited administrator of child from parent).

I fixed this problem with the attached patch.

Cheers,
Andrei

P.S. This is related to #1435206, #2335161, #1281394, too.

abautu’s picture

Status: Postponed (maintainer needs more info) » Needs review
amitaibu’s picture

@abautu I'm not clear on how to reproduce this. If you could provide a simpleTest it will surely help get this patch in...

abautu’s picture

@amitaibu: Create private group A, with private subgroup B. Enable user inheritance for A. Create a node that has audience both A and B, you should get the SQL error.

mwidner’s picture

I was experiencing the same issue from a hook_update_N() call for a custom module that was changing the group content access value for a bunch of nodes. The patch in #5 fixed the problem for me.