The latest dev version of Rules, the latest beta of Content Access module, Drupal 7.17 and Postgres are installed. Content Access rules integration is used to assign permissions to a single webform when the webform is newly created. Per-node access settings are enabled.
PDOException: SQLSTATE[23505]: Unique violation: 7 errors: Unique-Constraint »node_access_pkey«: 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 ( ) in node_access_write_grants() (line 3440 drupal7/modules/node/node.module).
This error does not occurr when updating an existing document and priveleges arre assigned correctly via rules and content access.
When creating the rule for assigning the grant of the webform following error occurred when adding the grant access... action of the content access module.
•Notice: Array to string conversion in RulesTokenEvaluator->prepare() (line 153 drupal7/sites/all/modules/rules/modules/system.eval.inc).
This appeared in the status message about 5 or 6 times. But the action was saved.
It seems to be that Rules writes the webform record to the database and, then the Node module which tries it but fails due duplicate key violation.
This is the rule:
{ "rules_assignpermissiontoemployer" : {
"LABEL" : "AssignPermissionToEmployer",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "content_access_rules" ],
"ON" : [ "node_insert", "node_update" ],
"IF" : [
{ "node_is_of_type" : { "node" : [ "node" ], "type" : { "value" : { "webform" : "webform" } } } },
{ "AND" : [] },
{ "entity_has_field" : { "entity" : [ "node" ], "field" : "field_grpid" } },
{ "AND" : [] },
{ "data_is" : {
"data" : [ "node:grpid" ],
"value" : "empl"
}
}
],
"DO" : [
{ "content_access_action_grant_node_permissions" : {
"node" : [ "node" ],
"content_access" : { "value" : { "view:empl" : "empl" } }
}
}
]
}
}
Comments
Comment #1
thatoneguy CreditAttribution: thatoneguy commentedA similar problem also occurs when using workflow_rules. In my case, I was trying to set up a rule to publish content based on the content's workflow state. I had to rely on a transition rather than checking the new state as the former triggered when content was created. Once I configured the rule to check the prior state (which would require the content already exist), the rule worked fine. Based on that fact, I suspect might be a problem with node_insert rules; perhaps the module is trying to update a node that doesn't exist or change a node that doesn't yet exist?
Comment #2
lollipopp CreditAttribution: lollipopp commentedThe issue has been solved so far... Maybe this helps you as well.
Please have a look at
http://drupal.org/node/1892104
Comment #3
TR CreditAttribution: TR commentedOriginal poster reported in #2 that the problem is solved by a patch to the Content Access module - #1892104: Drupal fails to save a document with content access and rules integration.
The issue raised in #1 seems to be different, and if it's still a problem with the current version of Rules you should open a new issue for that.