Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I noticed that a properly saved node (using the UR + original drupal node form) has this array in the $node :
[user_relationship_node_access] => Array
(
[1] => Array
(
[view] => 1
)
)
So when I need to save the node using node_save (with custom form) I tried to use :
$user_relationship_node_access = array('1' => array('view' => TRUE));
$newnode->user_relationship_node_access = $user_relationship_node_access;
$node = node_submit($newnode);
// Save the node
node_save($node);
and the user_relationship array result always comes empty like this :
[user_relationship_node_access] => Array
(
)
What am I missing here? can anyone help?
Thanks in advance
Comments
Comment #1
spacer CreditAttribution: spacer commentedDuckzland - did you ever resolve this?
I'm seeing same problem on node_save - it resets the array for ur_node access, and clears any relationships set against the node.
Comment #2
duckzland CreditAttribution: duckzland commentedNo solution yet here, could you post yours if you found one?
Comment #3
spacer CreditAttribution: spacer commentedThe problem seems to be something to do with the node_api function in the user_relationship_node_access module.
In the latest dev release of the user_relationship_node_access.module (bundled with UR) - on line 273 the node object '$node->user_relationship_node_access' is set to the value of the $user_relationship_node_access array. That's after the row for the node in the u_r_n_a db table has been deleted, and the empty value inserted in place of the original value(s).
That's as far as I've got - I think a different/additional piece of logic is required to set $user_relationship_node_access to avoid this problem.
I'll let you know if I find a solution - in the meantime, if anyone else has found a solution to this, please reply...
Thanks
Comment #4
mrf CreditAttribution: mrf commentedNot sure if this will help with this particular issue, but I've had some luck using drupal_execute to get around similar problems.
Comment #5
mrf CreditAttribution: mrf commentedI am going to assume that this is a symptom of the same bug being handled in #629774: Node Access Data Lost When Edited by Different User.
I'll test out node_save there as well. Marking this as a duplicate.