Answers.Body: <p>We upgraded to Smarty 4 by adjusting civicrm.settings.php</p>
  <pre><code>define('CIVICRM_SMARTY_AUTOLOAD_PATH', '/home/agwstage/domains/staging.agw.ca/public_html/wp-content/plugins/civicrm/civicrm/packages/smarty4/vendor/autoload.php');
  </code></pre>
  <p>It resolved the problem. There were some old extensions that we disabled, but the message templates are working again.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-05-24T14:47:00.710Z
Answers.LastActivityDate: 2024-05-24T14:47:00.710Z
Answers.UserDisplayName: Stephen Karamatos
Answers.Body: <p>If going to Smarty 3 / 4 / 5 isn't a possibility for you yet, I found that removing the <code>{if call_user_func(</code> blocks from templates/CRM/Contact/Form/Task/Help/Email.id-from_email.hlp resolves this specific issue as a temporary workaround.</p>
  <p>Haven't figured out exactly why it's an issue yet. I can reproduce on a buildkit 5.73.3 site, but not on master.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-05-29T18:12:41.803Z
Answers.LastActivityDate: 2024-05-29T18:12:41.803Z
Answers.UserDisplayName: Chris Garaffa
Body: <p>After a recent upgrade, we are not able to produce letters anymore.  The error when trying is: <code>Network Error  Unable to reach the server. Please refresh this page in your browser and try again.</code> This error happens when the pop-up window is trying to open to display the letter template and preview.</p>
  <p>Digging a bit deeper, we can see the error:</p>
  <p><code>Message was not parsed due to invalid smarty syntax : Smarty error: [in evaluated template line 10]: syntax error: (secure mode) &amp;#039;call_user_func&amp;#039; not allowed in if statement (Smarty_Compiler.class.php, line 1398)</code></p>
  <p>We have removed all tokens from the template, and disabled many extensions, yet the problem still persists.</p>
  <p>Has anyone encountered this before and has a fix?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-05-23T15:40:35.750Z
Comments.Text: Do you have `call_user_func` in your template?
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-05-23T16:21:16.833Z
Comments.Text: I have removed all tokens from the message templates and still get the error. Not sure where the smarty templates are stored or generated from.
Comments.UserDisplayName: Stephen Karamatos
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-05-23T17:39:54.017Z
Comments.Text: I'm seeing this in an if statement where the WYSIWYG is converting ampersands to &#039, trying to generate letters.  Even though you've removed tokens, is there conditional logic somewhere in your letter template?
Comments.UserDisplayName: Lesley Carter - BackOffice
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-05-23T18:13:15.920Z
Comments.Text: Lesley good thought - that is another cause of errors but here 039 is just a single quote being double escaped when outputting the message.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-05-23T18:16:08.803Z
Comments.Text: Stephen when you say you don't know where the templates are, are these letters being created from a contribution search?
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-05-23T18:44:52.047Z
Comments.Text: We are going to try and edit civicrm.settings.php and just go to Smarty 4 and check to see if it breaks extensions.
  
  `define('CIVICRM_SMARTY_AUTOLOAD_PATH',
  '/home/agwstage/domains/staging.agw.ca/public_html/wp-content/plugins/civicrm/civicrm/packages/smarty4/vendor/autoload.php');`
Comments.UserDisplayName: Stephen Karamatos
Tags: <smarty><templates>
Title: CiviCRM update 5.73.1 appears to have broken smarty and we cannot generate letters
ThreadText: # CiviCRM update 5.73.1 appears to have broken smarty and we cannot generate letters
  
  (Asked by: username_0 on 2024-05-23)
  
  After a recent upgrade, we are not able to produce letters anymore. The error when trying is: `Network Error Unable to reach the server. Please refresh this page in your browser and try again.` This error happens when the pop-up window is trying to open to display the letter template and preview.
  
  Digging a bit deeper, we can see the error:
  
  `Message was not parsed due to invalid smarty syntax : Smarty error: [in evaluated template line 10]: syntax error: (secure mode) 'call_user_func' not allowed in if statement (Smarty_Compiler.class.php, line 1398)`
  
  We have removed all tokens from the template, and disabled many extensions, yet the problem still persists.
  
  Has anyone encountered this before and has a fix?
  
  **Tags:** smarty, templates
  
  > **Comments:**
  > **username_1**: Do you have `call_user_func` in your template?  
  > **username_0**: I have removed all tokens from the message templates and still get the error. Not sure where the smarty templates are stored or generated from.  
  > **username_2**: I'm seeing this in an if statement where the WYSIWYG is converting ampersands to &#039, trying to generate letters.  Even though you've removed tokens, is there conditional logic somewhere in your letter template?  
  > **username_1**: Lesley good thought - that is another cause of errors but here 039 is just a single quote being double escaped when outputting the message.  
  > **username_1**: Stephen when you say you don't know where the templates are, are these letters being created from a contribution search?  
  > **username_0**: We are going to try and edit civicrm.settings.php and just go to Smarty 4 and check to see if it breaks extensions.  `define('CIVICRM_SMARTY_AUTOLOAD_PATH', '/home/agwstage/domains/staging.agw.ca/public_html/wp-content/plugins/civicrm/civicrm/packages/smarty4/vendor/autoload.php');`  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2024-05-24. Score: 1 | Accepted answer
  
  We upgraded to Smarty 4 by adjusting civicrm.settings.php
  define('CIVICRM_SMARTY_AUTOLOAD_PATH', '/home/agwstage/domains/staging.agw.ca/public_html/wp-content/plugins/civicrm/civicrm/packages/smarty4/vendor/autoload.php');
  
  It resolved the problem. There were some old extensions that we disabled, but the message templates are working again.
  
  
  ---
  
  ### Answer by username_3 on 2024-05-29. Score: 0
  
  If going to Smarty 3 / 4 / 5 isn't a possibility for you yet, I found that removing the `{if call_user_func(` blocks from templates/CRM/Contact/Form/Task/Help/Email.id-from\_email.hlp resolves this specific issue as a temporary workaround.
  
  Haven't figured out exactly why it's an issue yet. I can reproduce on a buildkit 5.73.3 site, but not on master.
  
  
  ---
  
  