Scheduled reminders fail silently if there is an error in the template
Overview
We have recently come across an issue whereby scheduled reminders weren't being sent but we were completely unaware this was happening. We managed to track it down to an error in the template for one of the event reminders we had set up - the template contained CSS and this caused a fatal error in Smarty.
PHP Fatal error: Smarty error: [in string:<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title></title>
<style type="text/css">html { font-size: 100%;}
html, button, input, select, textarea { font-family: sans-serif; }
body, h1, h2, h3, h4, h5, h6, p { margin: 0; }
table { border-collapse: collapse; border-spacing: 0; }
td img { display: block; }
...
The issue is that this stopped all scheduled reminders from being sent - not just the event reminder. This meant that none of our membership renewal reminder emails were being sent either. We were completely unaware of this because there was no visible error message in the UI.
Reproduction steps
- Create a scheduled reminder that works correctly.
- Check that this is sending emails as expected.
- Create another scheduled reminder with CSS in the template (see above) so that it causes a Smarty error.
- Note that none of the scheduled reminder emails are being sent.
Current behaviour
CiviCRM fails silently when there is an error in a template for a scheduled reminder. This stops all scheduled reminders from being sent.
Expected behaviour
There are several things that should happen if there is an error in a Smarty template:
- CiviCRM alerts the user at the point of creating/editing a scheduled reminder with a Smarty error in the template.
- CiviCRM alerts the user if there is scheduled reminders fail to be sent - see #1933 (closed).
- CiviCRM should continue to send the other scheduled reminders as normal so only the reminder with an error fails, rather than no reminders being sent at all.
Environment information
- Browser: N/A
- CiviCRM: 5.33.5
- PHP: 7.3
- CMS: WordPress 5.4.6
- Database: Maria DB 10.3.23.
- Web Server: Nginx 1.15.0
Comments
See this post on StackExchange for info about the Smarty error: SMARTY error with template.