Details
-
Type: Bug
-
Status: Open
-
Priority: Critical
-
Resolution: Unresolved
-
Affects Version/s: 4.7.22, 5.9
-
Fix Version/s: None
-
Component/s: CiviMember
-
Labels:None
-
Versioning Impact:Major (incompatible API change)
-
Documentation Required?:None
-
Funding Source:Needs Funding
-
Verified?:No
Description
Suppose you have an organization membership. Suppose the organization has 4 related contacts, each of whom inherits the membership.
Suppose you then add a related contact.
Suppose you then renew the membership.
The newly related contact does not receive the inherited membership. In fact, each time you save / update the membership, an apparently random set of 4 related contacts receives the inherited membership.
============
This turns out to be a bug in Member/BAO/Membership.php. At line 1445, we see
if ($relMembership->find(TRUE)) {
$params['id'] = $relMemIds['membership'] = $relMembership->id;
}
However, params['id'] is never initialized, so if some related memberships are not found, they are assigned the ID from the last iteration through the loop – meaning the previous contact loses their membership.
The solution is to add $params['id'] = NULL right before. (It would probably be better to set $params = NULL at the beginning of the loop, but I haven't tested that.)
I haven't submitted a patch, but it should be straightforward.