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

dev/core#434: Check If 'absolute_date' Is Used In 'prepareRepetitionEndFilter' To Prevent SQL Error #12923

Merged

Conversation

vinuvarshith
Copy link
Contributor

@vinuvarshith vinuvarshith commented Oct 11, 2018

Overview

When adding a scheduled reminder with an 'absolute_date' initially and then enabling 'Repeat'and adding conditions results in an SQL error when executed.

Before

SQL systax error because of empty datefield
Produces SQL with condition something like the following (notice empty value in DATE_ADD)
...AND ("20181219180831" <= DATE_ADD(, INTERVAL 9 day))

After

SQL is fixed by checking if datefield is empty and replacing it with absolute_date

Technical Details

A function in Civi\ActionSchedule\RecipientBuilder.php, 'prepareRepetitionEndFilter' expects a date field which would be empty when using an 'absolute_date'. This causes the SQL query to be constructed with an empty string inside thus creating a syntax error.
Edit:
Its more appropriate to handle this in CRM/Event/ActionMapping.php createQuery() method and make sure 'casDateField' param is not empty. PR updated.

@civibot
Copy link

civibot bot commented Oct 11, 2018

(Standard links)

@civibot civibot bot added the master label Oct 11, 2018
@eileenmcnaughton
Copy link
Contributor

@vinuvarshith We'd really need to get a unit test with this one to get it merged since it touches some pretty critical & pretty deep stuff - have you written tests for CiviCRM before?

@seamuslee001
Copy link
Contributor

ping @jtwyman i think this might be the issue we are hitting with our reminders

@vinuvarshith vinuvarshith force-pushed the scheduled-reminders-error-fix branch from 70087a4 to 3c4dab7 Compare October 12, 2018 06:18
@vinuvarshith vinuvarshith force-pushed the scheduled-reminders-error-fix branch 2 times, most recently from e192647 to ba6673f Compare December 19, 2018 18:26
@vinuvarshith
Copy link
Contributor Author

On looking into this a bit more, the issue is that 'casDateField' param is empty when start_date is not given (but absolute_date is given) on CRM/Event/ActionMapping.php under createQuery() method.
I have update the PR to handle this.
@eileenmcnaughton Can you pls take another look?
Do you still want me to add tests? (as we are not touching critical areas)

@seamuslee001
Copy link
Contributor

Given that this creates a hard fail and that we have had some user testing of this PR according to another ticket https://lab.civicrm.org/dev/core/issues/637#note_12388. This code looks pretty safe now i'm going to add merge on pass to this

@seamuslee001
Copy link
Contributor

Jenkins re test this please

@seamuslee001
Copy link
Contributor

I'm going to merge this as it fixes a fatal and i think the code is pretty safe. Also Eileen was ok with merging if i was

@seamuslee001 seamuslee001 merged commit c8115b6 into civicrm:master Jan 8, 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