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

spacer’s picture

Version: 6.x-1.0-rc4 » 6.x-1.x-dev

Duckzland - 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.

duckzland’s picture

No solution yet here, could you post yours if you found one?

spacer’s picture

The 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

mrf’s picture

Not sure if this will help with this particular issue, but I've had some luck using drupal_execute to get around similar problems.

mrf’s picture

Status: Active » Closed (duplicate)

I 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.