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] Reduce calls to CRM_Member_PseudoConstant::membershipType #17987

Merged
merged 1 commit into from
Jul 30, 2020

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

Switches code to use recommended function which, bonus, is cached

Before

$membershipType = CRM_Member_PseudoConstant::membershipType($entityObj->membership_type_id)

After

CRM_Core_PseudoConstant::getLabel('CRM_Member_BAO_Membership', 'membership_type_id', $entityObj->membership_type_id);

Technical Details

This function defaults to not using the cached version so that's a pretty good argument for making a more
active effort to deprecate it. The createMembership function flushes it so we don't need to do that
so much in tests now either. I also included swapping status over in the test

Comments

@civibot
Copy link

civibot bot commented Jul 29, 2020

(Standard links)

$membershipType = CRM_Member_PseudoConstant::membershipType($entityObj->membership_type_id);
$subject = $membershipType ? $membershipType : ts('Membership');

if (is_array($subject)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can see in the line above this is not an array....

$this->callAPISuccessGetSingle('Activity', [
'activity_type_id' => 'Membership Signup',
'source_record_id' => $membershipID,
'subject' => 'General - Payment - Status: test status',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tests the altered lines

@eileenmcnaughton eileenmcnaughton force-pushed the pseudo_mem branch 2 times, most recently from 94dbf49 to 0067191 Compare July 29, 2020 00:22
1 Outdated
@@ -0,0 +1,24 @@
Reduce calls to CRM_Member_PseudoConstant::membershipType
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton please remove this file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dang

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gone by lunchtime (yours, not mine)

$subject = implode(", ", $subject);
}
$membershipType = CRM_Core_PseudoConstant::getLabel('CRM_Member_BAO_Membership', 'membership_type_id', $entityObj->membership_type_id);
$subject = $membershipType ?: ts('Membership');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this not be ??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same as

if ($membershipType) {
$membershipType;
}
else {
ts('Membership')
}

Whereas ?? is
if (isset($membershipType)) {
$membershipType;
}
else {
ts('Membership')
}

This function defaults to not using the cached version so that's a pretty good argument for making a more
active effort to deprecate it. The createMembership function flushes it so we don't need to do that
so much in tests now either. I also included swapping status over in the test
@eileenmcnaughton eileenmcnaughton changed the title Reduce calls to CRM_Member_PseudoConstant::membershipType [REF] Reduce calls to CRM_Member_PseudoConstant::membershipType Jul 29, 2020
@seamuslee001
Copy link
Contributor

Jenkins re test this please

@seamuslee001 seamuslee001 merged commit dbca14f into civicrm:master Jul 30, 2020
@seamuslee001 seamuslee001 deleted the pseudo_mem branch July 30, 2020 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants