The following scenario is given:
Drupal7, rules 7, content access (beta version) and Postgresql are used.
When a webform is saved rules triggers setting of permissions. At initial saving, this fails. Following error message occurrs:
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).

Saving the document without using rules integration and setting permissions later works well.

The patch attached solves this problem.
Cause: Rules integration of content access checks the node operation which initially is 'save'. If this is not the case (such as 'update' it will trigger node_access_acquire_grants($node).
So initially this shoud not happen because of multiple calls of this method (see comment of the integration).
Nevertheless, this happens due the German localization of Drupal is used and the operation is translated, too.
Hence, t('save') has to be compared against instead of 'save'.
Please apply this patch in the upcoming release as quick as possible.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lollipopp’s picture

Assigned: lollipopp » Unassigned
lollipopp’s picture

Version: 7.x-1.2-beta1 » 7.x-1.2-beta2

When is this patch gonna be integrated?
There is still the same problem with the beta2 version.
Please integrate the patch asap.

wescleyteixeira’s picture

I also have this trouble. I tried to pass an user profile information to a content type when a new node is created via rules and i receive this message. Disabling Content Acess my site works fine.

colan’s picture

Issue summary: View changes
Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, content_access_rules.patch, failed testing.

gilsbert’s picture

Version: 7.x-1.2-beta2 » 7.x-1.x-dev
Status: Needs work » Reviewed & tested by the community
FileSize
698 bytes

Hi.

I wrote a new patch.

All the credits should be given to "lollipopp" who wrote the original patch!

I'm just trying to fix the automatic test failures.

Anyway I would ask to content_access's maintainers to fix the code even if my patch fails too.
It is very simple: just check what lollipopp suggested. It is only one line to be changed!

from:
- (isset($node->op) && $node->op != 'Save')) {
to:
+ (isset($node->op) && $node->op != t('Save'))) {

I tested my patch using the last "git" and the last "dev" version and I got success on both of them.

Regards,
Gilsberty

  • gilsbert authored e260a90 on 7.x-1.x
    Issue #1892104 by gilsbert, lollipopp, gisle: Fixed fails to save a...
gisle’s picture

Status: Reviewed & tested by the community » Fixed

This is fixed in 7.x-1.x-dev.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.