user warning: Duplicate entry '148-7-view_own_owner' for key 1 query: INSERT INTO node_access
RSTaylor - July 29, 2009 - 15:46
| Project: | View own |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Description
When saving a node that has more than one nodereference field, a slew of SQL errors occurs.
I tracked it down to the following code, which appears to insert several copies of the same grant (one for each nodereference field), but I'm not sure what it's actually supposed to be doing:
<?php
if ($field['module'] == 'nodereference') {
$nid = $node->{$field_name}[0]['nid'];
$uid = $node->uid;
$type = $field['type_name'];
$permission = $edit_via_ref_content;
$edit_perm = in_array($permission, $default_permissions[$rid]) ? 1 : 0;
$permission = $delete_via_ref_content;
$delete_perm = in_array($permission, $default_permissions[$rid]) ? 1 : 0;
$view_any_content = $view_via_ref_content;
$view_perm = (($edit_perm || $delete_perm) ? 1 : in_array($view_any_content, $default_permissions[$rid]));
$grants[] = array(
'realm' => 'view_own_owner',
'gid' => $uid,
'grant_view' => $view_perm,
'grant_update' => $edit_perm,
'grant_delete' => $delete_perm,
'priority' => 0,
);
}
?>Also, the code just below that for userreferences appears to assume that no two userreference fields on the node will reference the same user, if they do, I think it will give the same errors:
<?php
$grants[] = array(
'realm' => 'view_own_owner',
'gid' => $uid,
'grant_view' => $view_perm,
'grant_update' => $edit_perm,
'grant_delete' => $delete_perm,
'priority' => 0,
);
?>