Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-20955 - Allow contact's second membership to inherit when created… #10745

Merged
merged 1 commit into from
Aug 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions CRM/Member/BAO/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -1344,9 +1344,11 @@ public static function sortName($id) {
* @throws \CRM_Core_Exception
*/
public static function createRelatedMemberships(&$params, &$dao, $reset = FALSE) {
// CRM-4213 check for loops, using static variable to record contacts already processed.
static $relatedContactIds = array();
if ($reset) {
// not sure why a static var is in use here - we need a way to reset it from the test suite
// We need a way to reset this static variable from the test suite.
// @todo consider replacing with Civi::$statics but note reset now used elsewhere: CRM-17723.
$relatedContactIds = array();
return FALSE;
}
Expand Down Expand Up @@ -1388,12 +1390,12 @@ public static function createRelatedMemberships(&$params, &$dao, $reset = FALSE)
);
}

// check for loops. CRM-4213
// remove repeated related contacts, which already inherited membership.
$relatedContactIds[$membership->contact_id] = TRUE;
// CRM-4213, CRM-19735 check for loops, using static variable to record contacts already processed.
// Remove repeated related contacts, which already inherited membership of this type.
$relatedContactIds[$membership->contact_id][$membership->membership_type_id] = TRUE;
foreach ($allRelatedContacts as $cid => $status) {
if (empty($relatedContactIds[$cid])) {
$relatedContactIds[$cid] = TRUE;
if (empty($relatedContactIds[$cid]) || empty($relatedContactIds[$cid][$membership->membership_type_id])) {
$relatedContactIds[$cid][$membership->membership_type_id] = TRUE;

//don't create membership again for owner contact.
$nestedRelationship = FALSE;
Expand Down