I have burned hours on this and feel at a wall. Would appreciate some fresh eyes to shed light on new avenues of exploration.
I am using "find Contributions" to generate a list of contributions. I then choose "Thank you letters" and then choose the template I created.
In the template I am using some Smarty code that I found online last year that summarizes contributions and creates a neat table:
{foreach from=$contributions item=contribution}
{assign var="date" value=$contribution.receive_date|date_format:"%d %b %Y"}
<tr>
<td>{$date}</td>
<td style="text-align:right;">${$contribution.total_amount|number_format:2:".":","}</td>
<td>{$contribution.payment_instrument}{if $contribution.check_number neq""} - #{$contribution.check_number}{/if}</td>
<td>{$contribution.campaign}</td>
<td>{$contribution.contribution_source}</td>
</tr>
{/foreach}
<tr>
<th>2020 TOTAL</th>
<th style="text-align:right;">${$contribution_aggregate|number_format:2:".":","}</th>
<th> </th>
<th> </th>
<th> </th>
</tr>
It works great on one site producing a neat table:
However, on another site on the same server, I get "There has been a critical error on this website. Please check your site admin email inbox for instructions."
Checking the Apache error log I find a somewhat non-specific error:
[Wed Dec 23 13:51:44.466136 2020] [php7:error] [pid 31786] [client maskedIP:43002] PHP Fatal error: Smarty error: [in string:<table align="left" border="1" cellpadding="5" cellspacing="0" class="table" style="margin-top:15px;">\r\n\t<tbody>\r\n\t\t<tr>\r\n\t\t\t<th>Date</th>\r\n\t\t\t<th style="text-align:right;">Amount</th>\r\n\t\t\t<th>Method</th>\r\n\t\t\t<th>Campaign</th>\r\n\t\t\t<th>Note</th>\r\n\t\t</tr>\r\n\t\t<!--\r\n {foreach from=$contributions item=contribution} {assign\r\n var="date" value=$contribution.receive_date|date_format:"%d %b\r\n %Y"}\r\n -->\r\n\t\t<tr>\r\n\t\t\t<td>{$date}</td>\r\n\t\t\t<td style="text-align:right;">${$contribution.total_amount|number_format:2:".":","}</td>\r\n\t\t\t<td>{$contribution.payment_instrument}{if $contribution.check_number neq""} - #{$contribution.check_number}{/if}</td>\r\n\t\t\t<td>{$contribution.campaign}</td>\r\n\t\t\t<td>{$contribution.contri in /var/www/masked-url.org/wordpress/wp-content/plugins/civicrm/civicrm/packages/Smarty/Smarty.class.php on line 1100, referer: https://masked-url.org/wp-admin/admin.php?page=CiviCRM&q=civicrm%2Fcontribute%2Fsearch&_qf_PDFLetter_display=true&qfKey=bd001d277ba51fe3447c1acb3c2bed4dceb754c89022040c362d62bb4e04b4b3_9738
I have disabled entities in the CKEditor on both sites:
I have ensured Smarty is enabled in message templates and the error log confirms that because the error is clearly Smarty related.
I have literally cut-and-pasted the code from one site to the other and not changed it in any way.
I am able to do a very simple test successfully by putting the following code into a template:
<p>{$smarty.now|date_format}</p>
<p>{$smarty.version}</p>
I get valid output for that simple test on both sites:
I have also tried writing other Smarty code, but have had no luck getting anything other than that basic case to work. Likely that has at least something to do with my limited Smarty experience. However, the first code I shared works just great on one site and fails on the other.
Site 1 (works): WordPress 5.6, PHP 7.3.22, CiviCRM 5.30.0, Smarty 2.6.31 (though this seems very old so I expect it has been the CiviCRM version for a long time)
Site 2 (doesn't work - error above): WordPress 5.6, PHP 7.3.22, CiviCRM 5.32.2, Smarty 2.6.31
While the CiviCRM versions differ, I would hope that this is not a regression. It seems especially unlikely since the Smarty version has not changed.
Hoping someone can shed light or offer other places to look for useful logs that might provide a clue.
CRM_Core_Error::debug_log_message($error_msg);
just before line 1099 in packages/Smarty/Smarty.class.php and then you'll be able to see the full error and what it doesn't like by looking in ConfigAndLog.