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

[REF] simplify retrieval of existing membership on membership renewal form #18296

Merged
merged 1 commit into from
Aug 31, 2020

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

Minor code simplification on membership renewal form

Before

$currentMembership = CRM_Member_BAO_Membership::getContactMembership($contactID, $membershipTypeID,
      $is_test, $membershipID, TRUE
    );

getContactMembership is hard to read

After

$currentMembership = civicrm_api3('Membership', 'getsingle', ['id' => $membershipID]);

Technical Details

After stepping through the code I determined that if membershipID is passed into getContactMembership then it either

  1. returns the membership id much like membership.get but with is_current_member calculated or
  2. returns the owner membership in a similar format

However, the renewal form is not visible for a non-owner membership so getting the owner membership is cruft
from another form & only 1 applies. Calling the api is much more transparent

Comments

Cover in MembershipRenewalTest

… form

After stepping through the code I determined that if membershipID is passed into getContactMembership then it either
1) returns the membership id much like membership.get but with is_current_member calculated or
2) returns the owner membership in a similar format

However, the renewal form is not visible for a non-owner membership so getting the owner membership is cruft
from another form & only 1 applies. Calling the api is much more transparent
@civibot
Copy link

civibot bot commented Aug 31, 2020

(Standard links)

@civibot civibot bot added the master label Aug 31, 2020
@colemanw
Copy link
Member

Change makes sense to me.

@colemanw colemanw merged commit 98df40f into civicrm:master Aug 31, 2020
@colemanw colemanw deleted the curr_member branch August 31, 2020 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants