dev/core#434: Check If 'absolute_date' Is Used In 'prepareRepetitionEndFilter' To Prevent SQL Error #12923
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.