This issue originally was created for the following reason:

This has bugged me for quite a while, but I thought maybe there was some legitimate use for this. But over time I realized it's just a bug and needs to be removed...

invite_by_email's invite_presave overrides the invitee if a user exists with the email address of the invitation. In both cases of when this code actually makes a difference, the behavior is not desirable:

1)
- User A sends invite to email address associated with EXISTING USER B:
X New invitation is created with invitee already set to user B

2)
- User A sends invite to nonexistinguserb@example.com
- nonexistinguserb@example.com joins as userb without using the invite
- nonexistinguserc joins as userc using the invite
X invitee is set to userb instead of userc

The thing I *think* was intended was to catch cases where a user joins without using the invitation, and to match the user that way. But it's not achieving that goal anyway, and that would be best done in an invite_by_email_user_insert.

When I was reviewing the original patch I became frustrated because the code was more complex and difficult to understand than it needed to be.

Patch #6 fixes the issue and simplifies the code.

Comments

captainack created an issue. See original summary.

captainack’s picture

Status: Active » Needs review
StatusFileSize
new694 bytes
captainack’s picture

Committer please ignore this comment ;) #2 is the correct patch.

I just wanted to attach a patch against 4.0-beta2 as well, in case someone is pinned to it for a while.

socialnicheguru’s picture

I can't get either of these to apply to the dev version

socialnicheguru’s picture

Status: Needs review » Needs work
SpartyDan’s picture

Status: Needs work » Needs review
StatusFileSize
new2.01 KB

I agree that

In both cases of when this code actually makes a difference, the behavior is not desirable.

My patch includes rewriting the invite_by_email_invite_presave function.

I eliminated the use of entity metadata wrapper. IMO it increased code complexity and decreased readability.

I also reordered some of the code into a more logical order.

Please review and let me know if you encounter any problems.

I do not plan to commit this code until a couple of other people have reviewed it.

SpartyDan’s picture

Title: invite_by_email messes up invitees in some cases » Revise function invite_by_email_invite_presave
Issue summary: View changes
SpartyDan’s picture

Assigned: captainack » Unassigned
SpartyDan’s picture

Status: Needs review » Fixed

Patch #6 committed.

  • SpartyDan committed cd4d5a9 on 7.x-4.x
    Issue #2626076 by captainack, SpartyDan: Revise function...

Status: Fixed » Closed (fixed)

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