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

Further deprecate use of $ids array in membership functions #14887

Merged
merged 1 commit into from
Jul 29, 2019

Conversation

mattwire
Copy link
Contributor

Overview

Incremental progress towards removing deprecated code.

Before

$ids passed in more places.

After

$ids passed in less places.

Technical Details

Comments

@eileenmcnaughton per similar work you've done

@civibot
Copy link

civibot bot commented Jul 26, 2019

(Standard links)

@civibot civibot bot added the master label Jul 26, 2019
@@ -356,14 +349,22 @@ public static function create(&$params, &$ids = [], $skipRedirect = FALSE) {
//record contribution for this membership
if (!empty($params['contribution_status_id']) && empty($params['relate_contribution_id'])) {
$memInfo = array_merge($params, array('membership_id' => $membership->id));
$params['contribution'] = self::recordMembershipContribution($memInfo, $ids);
$params['contribution'] = self::recordMembershipContribution($memInfo);
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that we are no longer passing in $ids['contribution'] & nor are we passing in $memInfo['contribution_id'] so we might need to be loading & passing that in instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

$ids['contribution'] can only be set if we've already called CRM_Member_BAO_Membership::create() which we haven't, as we're calling this from create()

Arguably we don't need the $params['contribution_id'] check in recordMembershipContribution() as I think it will always be empty, but it seemed sensible given the need for further refactoring in this area.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused - if $ids['membership'] is set & it's an update the $ids['membership'] would be set so it would load $ids['contribution'] in the rows above (before your removal)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:-( Looks like I am too... Have undone a bit of the refactor so we set $params['contribution_id'] before calling self::recordMembershipContribution. I'm still pretty sure that neither $ids['contribution' or $params['contribution_id'] will be set at this point but the code is now less "risky" for a first round.

@eileenmcnaughton
Copy link
Contributor

I think we do have pretty good test cover here

@mattwire mattwire force-pushed the membership_deprecateids branch from 0766c5f to a01c34d Compare July 28, 2019 11:14
@mattwire
Copy link
Contributor Author

@eileenmcnaughton I've reviewed (and resolved) your comments. I've added a load more comments reflecting the work I did to track where $ids is being set - which should help with review, and anyone who wants to continue the removal of $ids later (the next step is to stop it being passed by reference as that will remove most of the $ids straight away).

@mattwire
Copy link
Contributor Author

@eileenmcnaughton Try again :-)

@seamuslee001
Copy link
Contributor

changes look fine to me now @mattwire can you squish your commits together please

@mattwire mattwire force-pushed the membership_deprecateids branch from 113706d to f57cb50 Compare July 29, 2019 09:03
@mattwire
Copy link
Contributor Author

@seamuslee001 @eileenmcnaughton Squashed!

@eileenmcnaughton
Copy link
Contributor

unrelated fail

@eileenmcnaughton eileenmcnaughton merged commit c2fe8e9 into civicrm:master Jul 29, 2019
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