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

Fix for ongoing issues with static upsetting the apple cart #18245

Merged
merged 1 commit into from
Sep 7, 2020

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Aug 24, 2020

Overview

This is an alternate to #18218

Before

Under various edge cases - including the one in the test & in #18218 inherited memberships are not created

After

Memberships created more reliably

Technical Details

This removes a static variable which was intended to prevent a loop in https://issues.civicrm.org/jira/browse/CRM-4213

The static has caused various ongoing bugs - including https://issues.civicrm.org/jira/browse/CRM-19735 which got past it by flushing the static. Fundamentally the static is not reliable enough so I've switched to looking up & checking existing memberships.

I think it might mean more queries but they shouldn't be expensive queries & the
code is just too hard-going to skip straight from hacked but still intermittently buggy to 'good' (I won't pretend perfect was the enemy of good here- good was the enemy of 'not truly awful')

Comments

CRM-17723 was also a bug this static was interacting with

@civibot
Copy link

civibot bot commented Aug 24, 2020

(Standard links)

@mattwire
Copy link
Contributor

@eileenmcnaughton Checkstyle and conflict

@eileenmcnaughton
Copy link
Contributor Author

Ah yes - this conflicted with the other

@eileenmcnaughton eileenmcnaughton force-pushed the loop branch 2 times, most recently from 5beebab to ea59032 Compare August 24, 2020 21:31
@eileenmcnaughton
Copy link
Contributor Author

@agh1 or @MegaphoneJon or @agileware-pengyi is this something one of you would be able to review?

@MegaphoneJon
Copy link
Contributor

I can have someone start reviewing today or the day following.

@eileenmcnaughton
Copy link
Contributor Author

Thanks @MegaphoneJon

@eileenmcnaughton
Copy link
Contributor Author

Hmm - I'd better check those test fails!

@eileenmcnaughton
Copy link
Contributor Author

OK - test fails required me to remove old hacks....

@lalgwebdev
Copy link

@eileenmcnaughton I can confirm that this fixes the problem described in #18218.

However there is now a different fault. When the status of the primary Membership is changed to Expired from e.g. Current or Grace, this does not propagate to the related Membership(s). Other changes I have tried do propagate. I have seen this when changing the end date manually - I have not tried when running the Process Memberships scheduled job.

@eileenmcnaughton
Copy link
Contributor Author

@lalgwebdev thanks for checking - I think that is the issue the remaining failing test might be picked up too.

You are testing through back office membership edit form?

@eileenmcnaughton
Copy link
Contributor Author

Failing job api_v3_JobTest.testProcessMembershipUpdateStatus

@eileenmcnaughton
Copy link
Contributor Author

I've fixed the test - I think this will fix the front end issue too...

@lalgwebdev
Copy link

@eileenmcnaughton Yes - this is now working when I test it (through the administrator's edit membership form).

@MegaphoneJon
Copy link
Contributor

@eileenmcnaughton Test fails relate.

@lalgwebdev It looks like you're taking on review/testing, is that correct?

This is an alternate to civicrm#18218

I managed to replicate the bug in https://issues.civicrm.org/jira/browse/CRM-4213 that the static
was added to cover. This takes an alternate approach of loading the memberships & checking them
rather than a static. I think it might mean more queries but they shouldn't be expensive queries & the
code is just too hard-going to skip straight from hacked but still intermittantly buggy to also having no additional
queries
@eileenmcnaughton
Copy link
Contributor Author

test this please

@eileenmcnaughton
Copy link
Contributor Author

@lalgwebdev I made another change for the test fail - can you double check again?

@lalgwebdev
Copy link

@eileenmcnaughton Yes, this works OK.

@MegaphoneJon
Copy link
Contributor

Ah, OK, I get it now. I thought there was some unnecessary recursion, and I didn't realize that createRelatedMemberships() is called from within create(), but now I see it all. This makes sense, I think it's good to merge.

@seamuslee001 seamuslee001 merged commit 36506f7 into civicrm:master Sep 7, 2020
@seamuslee001 seamuslee001 deleted the loop branch September 7, 2020 20:46
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.

5 participants