In user_relationships_request_relationship the following code
function user_relationships_request_relationship($requester, $requestee, $type, $approved = FALSE) {
// translate an ID into an object
foreach (array('requester' => $requester, 'requestee' => $requestee, 'type' => $type) as $key => $value) {
if (!is_object($value)) {
$$key = $key == 'type' ? user_relationships_type_load($value) : user_load(array('uid' => $value));
}
}
if (!variable_get('user_relationships_allow_multiple', TRUE)) {
if (user_relationships_load(array('user' => $requester->uid, TRUE)) || user_relationships_load(array('user' => $requestee->uid, TRUE))) {
return t('Users are not allowed to have multiple relationships');
}
}
should read
function user_relationships_request_relationship($requester, $requestee, $type, $approved = FALSE) {
// translate an ID into an object
foreach (array('requester' => $requester, 'requestee' => $requestee, 'type' => $type) as $key => $value) {
if (!is_object($value)) {
$$key = $key == 'type' ? user_relationships_type_load($value) : user_load(array('uid' => $value));
}
}
if (!variable_get('user_relationships_allow_multiple', TRUE)) {
if (user_relationships_load(array('user' => $requester->uid), TRUE) || user_relationships_load(array('user' => $requestee->uid), TRUE)) {
return t('Users are not allowed to have multiple relationships');
}
}
Patch attached.
Comments
Comment #1
ajayg commentedI see the changes you made. But what exactly are the consequances becasue of this to user? What behaviour you see that needed correction and you came up with the patch?
If I need to test this patch what is before and after behaviour for a user (or administrator)?
Comment #2
stashlbai commentedThe change reflects the fact that the old code was calling user_relationships_load with the wrong arguments; which meant that a function calling user_relationships_request_relationship in an environment allowing multiple relationships received incorrect results. This can be confirmed by examining the call signature of user_relationships_load(), which does not rationally accept a single array with 'user'->val, true as its components.
I think it would be more interesting for you to explain what the call
is trying to retrieve, in the code as it exists? What does TRUE do in the array as first argument?
Comment #3
jaydub commented#2 is right. The comments for the user_relationships_load() function show:
The 2nd parameter is a boolean which fits the patched function call shown above where the 1st parameter is just the array('user' => $requester->uid).
This is a moot point now though as this has been fixed in CVS already:
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/user_relati...