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
Comment | File | Size | Author |
---|---|---|---|
#5 | og_access.module.diff | 476 bytes | abautu |
Comments
Comment #1
slapierre CreditAttribution: slapierre commentedComment #2
arunverma CreditAttribution: arunverma commentedHi
Having same issue, when try to rebuild permission.
Any idea, please.
thx
Arun
Comment #3
shushu CreditAttribution: shushu commentedCan you please elaborate ?
Please describe the scenario that creates this situation, so we will be able to reproduce.
Comment #4
mikedoth CreditAttribution: mikedoth commentedI'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?
Comment #5
abautu CreditAttribution: abautu commentedI 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.
Comment #6
abautu CreditAttribution: abautu commentedComment #7
amitaibu@abautu I'm not clear on how to reproduce this. If you could provide a simpleTest it will surely help get this patch in...
Comment #8
abautu CreditAttribution: abautu commented@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.
Comment #9
mwidner CreditAttribution: mwidner as a volunteer commentedI 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.