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

Partial refactor of completeMembershipFromContribution #12271

Merged
merged 1 commit into from
Jun 8, 2018

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

This is a partial of #11556 - it contains part of that code tidy up

Before

Code less maintainable

After

Code more maintainable

Technical Details

@omarabuhussein I took a look at #11556 as we were discussing and this is about the size chunk I feel comfortable reviewing / merging .... and which I feel comfortable makes sense after reviewing the code myself

It moves the loading of related membership objects to the function that @mattwire has reworked - without actually changing it to an array as Matt does or changing the processing. I took a look at the paths by which updateMembershipBasedOnCompletionOfContribution is reached and I feel pretty comfortable it is equivalent to the result of $contributionDAO->loadRelatedMembershipObjects(); in all cases - that is the main change in here. I'm not too worried about the performance impact of potentially loading that twice. I don't think it's much in the scheme of things. If you feel comfortable with this portion we can merge it & get @mattwire to rebase the larger PR

Comments

@@ -2441,7 +2441,7 @@ public function loadRelatedObjects(&$input, &$ids, $loadAll = FALSE) {
}
}

$this->loadRelatedMembershipObjects($ids);
$ids = $this->loadRelatedMembershipObjects($ids);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

just ditching pass-by-param here

$trxnsData['trxn_date']
);
}
self::updateMembershipBasedOnCompletionOfContribution(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

pretty much per Matt's - load relatedObjects in updateMembershipBasedOnCompletionOfContribution & do early return in there too

@@ -4598,10 +4594,6 @@ public static function completeOrder(&$input, &$ids, $objects, $transaction, $re
self::repeatTransaction($contribution, $input, $contributionParams, $paymentProcessorId);
$contributionParams['financial_type_id'] = $contribution->financial_type_id;

if (is_numeric($memberships)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

memberships is defined as

$memberships = CRM_Utils_Array::value('membership', $objects);

so that line is meaningless

Copy link
Contributor Author

@eileenmcnaughton eileenmcnaughton Jun 6, 2018

Choose a reason for hiding this comment

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

& actually - $memberships not used anyway

);
}
self::updateMembershipBasedOnCompletionOfContribution(
$contribution,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

no memberships param

@omarabuhussein
Copy link
Member

this is good to merge from my side @eileenmcnaughton

@eileenmcnaughton
Copy link
Contributor Author

OK - let's do this & then next round can have some tests! Merging

@eileenmcnaughton eileenmcnaughton merged commit cda9094 into civicrm:master Jun 8, 2018
@eileenmcnaughton eileenmcnaughton deleted the membership branch June 8, 2018 10:47
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.

3 participants