Hi,

I notice a strange problem. When you go at http://mywebsite.com/relationship, the person who ask for a relation and this relation ship is approve by the other person, do not see the "friend". The person who accept the relationship will be able to see the person who ask in is list but not the other person.

Also, when the person accept the request, the person who made the requqest originaly can make another request to the same person again. So I think the two way relationship are not two way at all !!!

Could you please check it out. If you need to check what i'm talking about, I can send you the link to my website and check it out.

Thanks.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sw3b’s picture

Is anybody having the same issue, I install on a clean version of Drupal and the problem still there ?!?

Thanks

Sylense’s picture

Subscribing. I am having a similar issue. With user relationships set to be mutual the relationship only appears on the requester's side and it should appear on both ends.

sw3b’s picture

Yes and I did some testing on my side, if there is no confirmation, the relationship is both way. If there is confirmation the user who confirm the relationship will see is relation but the person who ask for it will not. Also if the person who accept try to remove the relationship from is list, it goes to a blank page or error page saying the link page is not available.

@berdir Any chance you can confirm this issue on your side too or your working on this ?!? Because this make the module no very usable for the relationship with users.

areynolds’s picture

Same issue here. It seems that a DB record is created upon sending out the request, showing a relationship between the requester and the requestee. However, upon the requestee accepting the relationship, the original record is erased and only a relationship between the requestee and the requester (with roles reversed in the DB fields) exists.

Ex:

  1. UID 6 requests friendship with UID 7
  2. Relationship record created: requester:6, requestee:7
  3. UID 7 accepts
  4. former relationship record erased, new created: requester:7 requestee:6
areynolds’s picture

Assigned: Unassigned » areynolds

Ok, think I found the issue. In the process of approving the relationship, the approval action was overwriting the existing DB entry instead of creating a new one. The drupal_write_record() in the following code from user_relationships.module shouldn't have a $keys argument; $keys argument indicates a new record, whereas the absence of $keys indicates an update:

      if ($relationship->approved && !$relationship_type->is_oneway) {
        $reversed_relationship = clone $relationship;
        $reversed_relationship->requestee_id = $relationship->requester_id;
        $reversed_relationship->requester_id = $relationship->requestee_id;
        drupal_write_record('user_relationships', $reversed_relationship, $keys);
      }

Seems to work when you remove the $keys argument. Patch to follow in a couple of minutes.

areynolds’s picture

Status: Active » Needs review
FileSize
648 bytes
sw3b’s picture

Status: Needs review » Reviewed & tested by the community

It seems to correct the problem on my side too ! Nice work...

Berdir’s picture

Component: User interface » Code
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Hm, yeah, I see.

The problem here is, that we are updating the initial relationship row, which is correct, but we need to insert a new one for the reverse relationship.

*However*, when, for whatever reason, that relationship is edited again, it should update and contain $keys instead of creating a new row, because that would lead to duplicates.

I think we should actually just stop using drupal_write_record() and use db_merge() here.

Also, tests for this would be awesome.

areynolds’s picture

Here's a patch using db_merge(). I'd love to write some tests, but I'm still getting the hang of the testing system.

areynolds’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, two-way-relationship-fails-1211060-9.patch, failed testing.

Berdir’s picture

key() needs to include requestee too.
Also, key fields must not show up in fields()

Babymaggie’s picture

Just upgraded to the latest version via drupal's own updater and I now have the same problem.

The only account registering the friendship is the person who accepts the friendship request.

Is there anyone still working on / looking at this bug?

I have completely uninstalled the module and restored the module from a backup to get the functionality working again.

Im now getting quite a list of module upgrades which have been broken :-(

Let's hope someone can fix this?

areynolds’s picture

Status: Needs work » Needs review
FileSize
1.18 KB

Ok, I included the requestee id and took out the key fields from fields(). Thanks for the help Berdir; it's good to get more familiar with db_merge().

Status: Needs review » Needs work

The last submitted patch, two-way-relationship-fails-1211060-14.patch, failed testing.

areynolds’s picture

Hmm, thought that would do it. Guess I'll have to learn something about the testing framework so I can understand the errors.

francois o’s picture

suscribing

Nicolas Bouteille’s picture

I encountered the same problem but it's great to see that you guys are already working on it!
Good luck to you and thank you!
Hope in a few months I'll have the experience to contribute on Drupal dev too. Right now I only now how to make use of modules...
++

ifish’s picture

yup.. same problem here

choosedrupal’s picture

Title: Two way relationship not showing on the person who ask relationship and relationship not keep » Two way relationship not showing on the person who ask relationship and relationship not keep - FIXED

Patch failed. Applied to 7.x-1.x-dev

FIXED BY:
//drupal_write_record('user_relationships', $reversed_relationship, $keys);
drupal_write_record('user_relationships', $reversed_relationship);

I did run into some problems with old database structures until I uninstalled UR and reinstalled it. The uninstall worked perfectly and did not require any additional effort.

GREAT WORK on this module!

BruFFy’s picture

choosedrupal, check #5 and #8
duplicates problem...

Berdir’s picture

Title: Two way relationship not showing on the person who ask relationship and relationship not keep - FIXED » Two way relationship not showing on the person who ask relationship and relationship not keep
heyay’s picture

It solved the problem for me too.
Thanks a bunch ! ! bro

Berdir’s picture

Status: Needs work » Needs review
FileSize
3.93 KB

Ok, here is an updated patch.

The problem with the previous one was simply that I renamed created_at and changed_at in the meantime.

I also simplified the code (there is no need for the clone stuff anymore) and added tests for this. These tests fail with the current code and would also fail with the drupal_write_record() approach.

Berdir’s picture

Trigger testbot

Berdir’s picture

Status: Needs review » Fixed

Tests pass, commited.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Liviu’s picture

It works, good job!

Thank you.

Anonymous’s picture

It works, great job

thanks a lot

dieppon’s picture

@Berdir thanks dude

jenlampton’s picture

Can we get a new release with this fix? thx! :)