-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
(dev/core#285) Fixed second membership reminder #13487
(dev/core#285) Fixed second membership reminder #13487
Conversation
(Standard links)
|
21b87b3
to
bf87fff
Compare
Hi there, nice work for the membership renewal scheduled reminders. I am not yet convinced this solution would be wise for event (and other) scheduled reminders. If I would change the start time of an event the day before. Would that trigger all of our 8 reminders relative to the start of the event again? I am all for better scheduled reminders functionality but also for better ways to configure in such a way we can prevent massive unintentional mails being sent out. So if this would be a checkbox in the UI I would endorse it right away. Checkbox: "re-evaluate when trigger date changes". I wonder how other people think about this. |
bf378f3
to
8df0128
Compare
Yeah. I think I was mislead by the simplicity. I've just pushed a version that works the same as the old way except it fixes the bugs. It should be pretty easy to add the UI checkbox later if someone wants to. |
0cc086f
to
fb96edd
Compare
@civicrm-builder retest this please |
@@ -1 +1,2 @@ | |||
{* file to handle db changes in 5.11.alpha1 during upgrade *} | |||
ALTER TABLE civicrm_action_log CHANGE COLUMN reference_date reference_date datetime; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dawnthorn what is the reasoning behind this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's so that this methodology of storing the reference date will work with all the kinds of entities, not just memberships. For example, for activities, the reference date is activity_date_time which is a datetime field. Making this field date time makes it work for both dates and datetimes.
064b1c2
to
4d1388a
Compare
I'm not sure where to put this, but the work for fixing this bug was sponsored by the EFF. |
The database migration will need to be updated to run on a later CiviCRM version. (Hopefully we can get this in soon without constantly revising that :) |
CRM/Event/ActionMapping.php
Outdated
@@ -158,7 +158,7 @@ public function createQuery($schedule, $phase, $defaultParams) { | |||
$query['casContactTableAlias'] = NULL; | |||
$query['casDateField'] = str_replace('event_', 'r.', $schedule->start_action_date); | |||
if (empty($query['casDateField']) && $schedule->absolute_date) { | |||
$query['casDateField'] = $schedule->absolute_date; | |||
$query['casDateField'] = "'{$schedule->absolute_date}'"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this feels wrong - why is it needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. This is wrong. Not because of the quoting I added though. We need to quote it because usually casDateField is a column name and gets added to the query raw. What's wrong with this is we need to escape it. I've pushed up a fix where I escape it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should also note that without the single quotes it causes a crash if you try and run an event scheduled reminder with an absolute date.
looking at this I think it needs pretty thorough engagement by someone else with skin in this issue (possibly @agh1 or @petednz or @JoeMurray or @seamuslee001 have? - although I may just be not letting good deeds go unpunished & suggesting the reward for having done work it be asked to do more) I will email the dev list. It looks like a valuable & much wanted change but it definitely needs a significant time commitment to review |
I emailed the dev-list to try to get reviewers for this |
Do I understand it correctly that this PR introduces the functionality of sending a second reminder, even if the membership is renewed? If so I do think this should be optional, as with a few clients with reminders configured in such a way that we are happy with the second reminder not going out because people already have paid for another year. |
@jaapjansma there's currently a bug in the following scenario:
|
@agh thanks for the explanation. I had a client who had problems with membership renewals. My first thought was that the batch was too large to be processed in one go. But it might be that it was this bug. |
@yashodha Can you please have yourself or @sushantpaste review this PR? Thanks. |
@Dawnthorn are you able to rebase this ? |
Can you please re-base this? |
In case it counts as a "review" of this PR, I would note that we are running this in production. |
@eileenmcnaughton the patch I posted was before this PR even existed, several weeks ago, for 5.7 Honestly, I'm surprised nobody noticed this bug before ... we have some sites where clients reported that membership reminders didn't go out, and it took some time to figure out why |
@jackrabbithanna I think there has been ongoing issues in this area that have never quite been addressed :-( I love the idea of getting a bank of tests into place (like this PR has) & tightening the noose on all the issues - I just haven't managed to get a ringing endorsement to merge yet |
I see now this patch does away with the code we patched in Civi/ActionSchedule/RecipientBuilder.php |
When I was reviewing the tests in 5.7 for this, I found that only one membership reminder was tested. Having a test where two memberships were created, end dates changed, and checking for 2 reminders go out would have caught the problem ... because the code in buildRelFirstPass() only updated the action log record dates for the first contact to get a reminder sent for the day, not the others. AFAIK |
WRT review-thresholds and potential conflicts, I think we're OK there. The main concern is that someone goes "easy" on a review because of a conflict - but I think @Dawnthorn and @mfb have been pretty rigorous. Additionally, we have had feedback from folks with a other perspectives (like @magnolia61's points about events) that were assimilated, and there's I haven't gotten my head deep enough into this PR to form an opinion on the other merits or on meta-review, but I thought it might be useful to clarify that bit about the formalities. |
@jackrabbithanna I think this PR adds those tests... |
@totten didn't say this above but on chat I pinged him to lightly skim the code for any red flags & at a high level he thought the code looked like it was on track |
@jackrabbithanna "Let me see if I can get this PR tested by our team" -> thank you |
@ all on this thread: THANK YOU! |
@@ -1 +1,2 @@ | |||
{* file to handle db changes in 5.14.alpha1 during upgrade *} | |||
ALTER TABLE civicrm_action_log CHANGE COLUMN reference_date reference_date datetime; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to go into a different file as 5.14 is released?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes - we can fix after merge I think - since it's already changed version a few times
@ALL so here is where I think we are at
After 6 months I'm not quite sure how to get 11 resolved. I'm also at this stage open to merging if the people on this thread together agree that I should merge it by commenting to that effect (which also implicitly means you are co-mergers on it & are morally obliged to jump in to help with any regressions). |
I might be jumping the gun with @jackrabbithanna's comment only being a few days ago - I'm just thinking about the rc being cut next week and a desire to hit that release |
Regarding 11, I would say please merge. However I have not and will not do any full review of the code. However there is an reason to merge this without a full review and loosing quality. The reason is that we favor as a community any contribution someone does and because we favor it we applaud and merge it (although there is a quality risk but we take that as a community). |
This is big and risky because of area. It adds tests and has been tested in production and focussed manual testing. I support merging and commit that JMA will assist with dealing with any regressions that result. |
Thanks for weighing in. I'll leave a few days for more input. Re " there is a quality risk but we take that as a community" - it's probably fairer to say there is a regression risk since the suite of tests in this improve our quality and robustness - which is a big plus on the 'merge' side to me. The issue is not our code quality standard but our review quality standards are at risk of not being hit here |
@mfb do you want to weigh in on what code review you have done / your in-production experience to give us more comfort with this change? Also anyone else want to weigh in on merging this - we have 2 * yay |
We haven't had a chance to test this one. My two cents: I do feel like this is a bug that needs killing. I like that this test was added: testMultipleMembershipEndDateMatch() ... how we experienced the bug was that one membership end date change would work for the sending of the reminder, but two, the second wouldn't .. and if this test can catch that .. that's great. I kind of feel like even if there are a couple of new bugs/regressions that come out of this, it's a step in the right direction, and kill those bugs (with more tests!) if they pop up. So add a yay. |
EFF folks reviewed this PR - but we don't have subject matter expertise re: CiviMember, that's why we hired Giant Rabbit to develop it :) |
@mfb what level of review did you do? ie did you understand the changes in the code? |
I read thru the code and have a general understanding of the concept of the changes being made, but our main contribution here is just funding the development and running it in production. |
@kcristiano @agh1 @Stoob @totten @MegaphoneJon and I discussed this on a hangout & agreed to merge this based on a verbal review - note after merge . upgrade will need fixing |
Fix upgrade version for #13487
Overview
With this change if you setup a reminder based on membership end date, the reminder will go out again if the membership is renewed and has a new end date.
Before
If you setup a scheduled reminder for memberships based on end date. It would send the first reminder, but if the user renewed their membership it wouldn't send out another reminder when the condition became true for the new end date.
After
Now it sends out a second reminder when the condition becomes true for the renewed membership.
Technical Details
I made the civicrm_activity_log.reference_date field a date time instead of just a date. This lets us always store the datetime that was used for the condition check. That way if the datetime changes (like the membership end date), we now know the condition needs to be checked again.
https://lab.civicrm.org/dev/core/issues/285