This is a great module. Exactly what I needed! However, I'm having a tough time setting permissions properly and so perhaps I just need a primer.

Use case:
I'm using only two content types "Basic" and "Private". All the basic nodes are created by admin and I want visible (VIEW ONLY) to the world. All private nodes are created by individual users and I want them to manage grants to individual user only for VIEW ONLY access and not by role. I only want the "View" - Allowed grants available to these node authors. I'm not using any other node type access module, unless you count Drupal's default.

If I understand the readme file correctly, once this module is enabled all nodes permissions will be handled by this module? So, I don't need to be concerned with any of the Drupal default settings for Node permissions in admin/people/permissions?

I'm hoping I've given enough info for you to basically tell me what boxes to check in each section of the nodeaccess settings page to make my use case work.

Below is the error I keep getting after trying to save a node.

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-1-nodeaccess_author' 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] => 1 [:db_insert_placeholder_1] => nodeaccess_author [:db_insert_placeholder_2] => 1 [:db_insert_placeholder_3] => 1 [:db_insert_placeholder_4] => 1 [:db_insert_placeholder_5] => 1 [:db_insert_placeholder_6] => 1 [:db_insert_placeholder_7] => nodeaccess_author [:db_insert_placeholder_8] => 1 [:db_insert_placeholder_9] => 1 [:db_insert_placeholder_10] => 1 [:db_insert_placeholder_11] => 1 ) in node_access_write_grants() (line 3564 of /home/xxx/public_html/xxx/modules/node/node.module).

Thank you in advance for any assistance!

Mark

Comments

System Lord’s picture

Issue summary: View changes
System Lord’s picture

StatusFileSize
new55.41 KB
new17.72 KB

I have to be missing something. I can create nodes with no issues, but if I go back to the node and re-save it I keep getting the error above. Both admin and users get this error. Attached is both the nodeaccess table and the node_access table. Maybe it will help figure this out?

System Lord’s picture

StatusFileSize
new11.37 KB
System Lord’s picture

Looks like this issue, or more likely just similar, has been addressed in core. However, I'm using D734 and the patch is included and I still get this error.

https://www.drupal.org/node/1146244

trigdog’s picture

Status: Active » Needs review
StatusFileSize
new823 bytes

I think this is a bug in the 7.x-1.x-dev version of this module. After the changes to the module to remove direct calls to node_access_write_grants, the nodeaccess_node_update function was changed from calling node_access_write_grants directly to saving the nodeaccess_author grant to the nodeaccess table but this is not necessary since nodeaccess_node_access_records automatically gets called during node update process also. nodeaccess_node_access_records loads the grants in the nodeaccess table (which will contain the nodeaccess_author grant added from nodeaccess_node_update) and then adds the nodeaccess_author grant a second time to the array before it gets sent on to node_access_write_grants creating the duplicate entry error above.

I have attached a patch with a fix for this.

trigdog’s picture

Title: Hard time with setting permissions » Database Error - nodeacess_author duplicate entry
trigdog’s picture

Title: Database Error - nodeacess_author duplicate entry » Database Error - nodeaccess_author duplicate entry

typo ;)

trigdog’s picture

Category: Support request » Bug report
System Lord’s picture

Thanks, trigdog. Testing now.

System Lord’s picture

No errors. Thank you! Since you know something about this module can you help me with what the heck "Keep?" is for? https://www.drupal.org/node/2423507 Sorry for using this thread, but I'm trying to find anyone that can help. This module is perfect for me in every way except for "Keep?" Confuses me and my users.

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

This seems to do the trick in fixing that error message. Tested unpublished/published and anonymous view vs not view. No error after patched;)

jduhls’s picture

#5 patch solved my problem too. Was getting same errors.

jduhls’s picture

@System Lord RE: #10 - agreed: "Keep?" is strange. Module needs some UI/UX work. If you uncheck it then click "save grants", it removes the user from grants.

hugovk’s picture

vlad.pavlovic, any chance to release this to dev? Thank you!

  • vlad.pavlovic committed f0f2bd8 on 7.x-1.x
    Issue #2427345 by trigdog: fix database error - nodeaccess_author...
vlad.pavlovic’s picture

Status: Reviewed & tested by the community » Fixed

Released to dev, sorry for delay.

Status: Fixed » Closed (fixed)

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