I've encountered the following error when trying to force save a node using the rules module, so that I can then perform some access checks on a newly created node.
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '49-4-taxonomy_access_role' 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); Array ( [:db_insert_placeholder_0] => 49 [:db_insert_placeholder_1] => taxonomy_access_role [:db_insert_placeholder_2] => 4 [:db_insert_placeholder_3] => 1 [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => 0 ) in node_access_write_grants() (line 3417 of /var/www/redacted/modules/node/node.module).
After tracking down a similar issue with the tac_lite module here http://drupal.org/node/1307114 I've started my investigation but am still having some trouble finding the fix.
Does anyone have any suggestions? It feels like somewhere in the node save process the grants are being calculated twice?
Comments
Comment #1
beauz CreditAttribution: beauz commentedAfter much headache I think I've fixed the problem.
I've changed taxonomy_access.module arround line 262 from:
to
This seems to have fixed the problem.
Comment #2
beauz CreditAttribution: beauz commentedI've now realised this is not the correct solution as the node_access table doesn't get written properly for instance when rebuild node access permissions is run.
I've come up with this rather hacky solution that checks the database for an existing row first and deletes it if there is a match, but there is probably a much better way to do this..
Comment #3
kenorb CreditAttribution: kenorb commented