I have a custom content type which reference many users.
I use the TAC lite module and view_own module in addition to the node access user reference module.
When i create or update any node of that content type, i get a duplicate entry warning.
See the full error below :
user warning: Duplicate entry '46-0-all' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (46, 'all', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2233.
user warning: Duplicate entry '46-0-all' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (46, 'all', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2233.
user warning: Duplicate entry '46-0-nodeaccess_userreference' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (46, 'nodeaccess_userreference', 0, 1, 1, 0) in /var/www/cedricm/modules/node/node.module on line 2233.
user warning: Duplicate entry '46-0-all' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (46, 'all', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2233.
user warning: Duplicate entry '46-0-nodeaccess_userreference' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (46, 'nodeaccess_userreference', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2233.
user warning: Duplicate entry '46-0-all' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (46, 'all', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2233.
user warning: Duplicate entry '46-0-nodeaccess_userreference' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (46, 'nodeaccess_userreference', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2233.
user warning: Duplicate entry '46-0-all' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (46, 'all', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2233.
user warning: Duplicate entry '46-0-nodeaccess_userreference' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (46, 'nodeaccess_userreference', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2233.
user warning: Duplicate entry '46-0-all' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (46, 'all', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2233.
user warning: Duplicate entry '46-0-nodeaccess_userreference' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (46, 'nodeaccess_userreference', 0, 1, 1, 0) in /var/www/cedricm/modules/node/node.module on line 2233.
user warning: Duplicate entry '46-0-all' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (46, 'all', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2233.
user warning: Duplicate entry '46-0-nodeaccess_userreference' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (46, 'nodeaccess_userreference', 0, 1, 1, 0) in /var/www/cedricm/modules/node/node.module on line 2233.
user warning: Duplicate entry '46-0-all' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (46, 'all', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2233.
user warning: Duplicate entry '46-0-nodeaccess_userreference' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (46, 'nodeaccess_userreference', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2233.
Comment | File | Size | Author |
---|---|---|---|
#15 | userref.patch | 2.18 KB | gunzip |
#12 | noderef.patch | 1.98 KB | gunzip |
Comments
Comment #1
danielb CreditAttribution: danielb commentedswitch to 1.4 mate (older version) I'll get this fixed.
Comment #2
danielb CreditAttribution: danielb commentedComment #3
PePiToO CreditAttribution: PePiToO commentedI just updated to the 6-1.6 version.
I did disable all the permissions module ( view_own and TAC lite ) , but there is still the same error when i enable the module and edit a node :
user warning: Duplicate entry '49-0-all' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (49, 'all', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2249.
user warning: Duplicate entry '49-0-all' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (49, 'all', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2249.
user warning: Duplicate entry '49-0-all' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (49, 'all', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2249.
user warning: Duplicate entry '49-0-nodeaccess_userreference' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (49, 'nodeaccess_userreference', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2249.
user warning: Duplicate entry '49-0-all' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (49, 'all', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2249.
user warning: Duplicate entry '49-0-nodeaccess_userreference' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (49, 'nodeaccess_userreference', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2249.
user warning: Duplicate entry '49-0-all' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (49, 'all', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2249.
user warning: Duplicate entry '49-0-nodeaccess_userreference' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (49, 'nodeaccess_userreference', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2249.
user warning: Duplicate entry '49-0-all' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (49, 'all', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2249.
user warning: Duplicate entry '49-0-nodeaccess_userreference' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (49, 'nodeaccess_userreference', 0, 1, 1, 0) in /var/www/cedricm/modules/node/node.module on line 2249.
user warning: Duplicate entry '49-0-all' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (49, 'all', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2249.
user warning: Duplicate entry '49-0-nodeaccess_userreference' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (49, 'nodeaccess_userreference', 0, 1, 1, 0) in /var/www/cedricm/modules/node/node.module on line 2249.
user warning: Duplicate entry '49-0-all' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (49, 'all', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2249.
user warning: Duplicate entry '49-0-nodeaccess_userreference' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (49, 'nodeaccess_userreference', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2249.
Comment #4
danielb CreditAttribution: danielb commenteddamn, the 1.6 version is just the same as the 1.5 version... I should have checked. I don't know how this happens I've definitly commited updated code.
I'm making a 1.7 and I will check to make sure.
Comment #5
danielb CreditAttribution: danielb commentedok she looks sweet
Comment #6
PePiToO CreditAttribution: PePiToO commentedi just updated and it seems to do the same problem again whether i save/rebuild content permission :
user warning: Duplicate entry '49-0-nodeaccess_userreference' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (49, 'nodeaccess_userreference', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2249.
user warning: Duplicate entry '49-0-nodeaccess_userreference' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (49, 'nodeaccess_userreference', 0, 1, 0, 0) in /var/www/cedricm/modules/node/node.module on line 2249.
It seems to work though
Comment #7
danielb CreditAttribution: danielb commentedThat's not the problem I fixed. I don't quite know what that is - can you try resaving node/49 ?
Comment #8
danielb CreditAttribution: danielb commentedComment #9
PePiToO CreditAttribution: PePiToO commentedNote that i am using Content Access 6.x-1.0 as well.
When i give a higher priority to Content Access module, it works fine ( as your module have less priority so the error does not come out ), but everytime your module have the priority, each time a node is saved this error appear.
Any idea ?
Comment #10
gunzip CreditAttribution: gunzip commentedThis happens to me if I use more than userreference cck field for a content type and two or more of them reference the same user.
More generally the access system is trying to assign different permissions to the same couple user => node.
If you use another content access module with higher priority this doesn't happen as the grants from userreference access
module are probably ignored in that case and not inserted into the table.
Technical info: this happens if the $grants array is populated with multiple permissions for the same uid => nid.
I think there should be a check in the foreach loop to use only the highest permissions.
Scenario:
1. two userreference fields points to the same user
2. the first one gives me the following rights: (view=1, delete=0, edit=0)
3. the second one gives me: (view=1, delete=1, edit=1)
then __only__ the second grants should be inserted into the array (i think).
I fixed this "hacking" the node access user reference module keying the grant array
$grants[$uid_$nid] = $grant
updating it only if the $grant variable contains higher rights, finally return array_values
(it's quite dirty so i'm not posting a patch)
Comment #11
PePiToO CreditAttribution: PePiToO commentedAny update on this ? will it be fixed in the next release ?
Comment #12
gunzip CreditAttribution: gunzip commentedcan you test this patch and give some feedback please ? thank you.
Comment #13
danielb CreditAttribution: danielb commentedI think a much simpler solution would be to construct the $grants array as $grants['uid']['grant_something'] instead of $grants[]['grant_something'], this would build the grants properly without having to check for the field that gives 'highest access'. The function node_access_acquire_grants() does not care about the keys of the array, so we can use it as an easy way to build unique records.
No need to use 'uid_nid' as everything in that function should be unique to one particular node.
Comment #14
danielb CreditAttribution: danielb commentedHere is how I would do it. Sorry I don't have time to set this up and test it atm.
Comment #15
gunzip CreditAttribution: gunzip commentedclever indeed. i made a patch with your code (to be tested).
Comment #16
PePiToO CreditAttribution: PePiToO commentedThis patch seems to work fine, thank you !
No more errors on create/edit projects with multiple users referenced more than 1 time and the access is working fine.
Comment #17
artis CreditAttribution: artis commented+1 for this patch working! I've applied it and it solved the issues I was having too. This should definitely get committed in the next release IMO.
Comment #18
artis CreditAttribution: artis commentedComment #19
danielb CreditAttribution: danielb commentedI've added this to the 2.0 betas
Comment #20
gunzip CreditAttribution: gunzip commentedi've seen in the latest beta you've dropped out the condition
but i think this was important because it assures that the privileges are the greatest possibile
(between multiple userreference in the same node) while without it the privileges gained are just the latest found,
(sorry if i'm wrong)
Comment #21
danielb CreditAttribution: danielb commentedoops