Answers.Body: <p>If you are on CiviCRM 5.70.x then it's a known issue which is fixed in the recent version. You can either apply the below patch and do db changes or upgrade CiviCRM to 5.72.x</p>
  <ol>
  <li>Patch file CRM/Event/DAO/Event.php</li>
  </ol>
  <pre><code>diff --git a/CRM/Event/DAO/Event.php b/CRM/Event/DAO/Event.php
  index 32de78e3325c..de7379737b04 100644
  --- a/CRM/Event/DAO/Event.php
  +++ b/CRM/Event/DAO/Event.php
  @@ -6,7 +6,7 @@
    *
    * Generated from xml/schema/CRM/Event/Event.xml
    * DO NOT EDIT.  Generated by CRM_Core_CodeGen
  - * (GenCodeChecksum:d63c53d10f2e09895a19061ea9d51093)
  + * (GenCodeChecksum:193894c0362eb3c7360ad8245e303fcf)
    */
   
   /**
  @@ -542,7 +542,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
     /**
      * Number of hours prior to event start date to allow self-service cancellation or transfer.
      *
  -   * @var int|string|null
  +   * @var int|string
      *   (SQL type: int)
      *   Note that values will be retrieved from the database as a string.
      */
  @@ -1994,6 +1994,7 @@ public static function &amp;fields() {
             'type' =&gt; CRM_Utils_Type::T_INT,
             'title' =&gt; ts('Self-service Cancellation or Transfer Time'),
             'description' =&gt; ts('Number of hours prior to event start date to allow self-service cancellation or transfer.'),
  +          'required' =&gt; TRUE,
             'usage' =&gt; [
               'import' =&gt; FALSE,
               'export' =&gt; FALSE,
  </code></pre>
  <ol start="2">
  <li>Run below query</li>
  </ol>
  <pre><code>UPDATE civicrm_event SET selfcancelxfer_time = 0 WHERE selfcancelxfer_time IS NULL;
  
  ALTER TABLE civicrm_event MODIFY COLUMN selfcancelxfer_time int(11) DEFAULT 0 NOT NULL COMMENT 'Number of hours prior to event start date to allow self-service cancellation or transfer.';
  
  
  </code></pre>
  <ol start="3">
  <li>Clear CiviCRM cache</li>
  </ol>
  <p>HTH</p>
  <p>Pradeep</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-05-07T08:35:55.537Z
Answers.LastActivityDate: 2024-05-07T08:35:55.537Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>I am having trouble with event registrations on an event that seemed to work fine a couple of months ago. The live event happened with no issues back in Jan and Feb. We've since re-activated the event as a gateway to access the videos. We changed the dates to keep it available and started taking registrations. I can't recall if we tested it then again or not.
  However, it is now crashing with &quot;There has been a critical error on this website&quot;</p>
  <p>The financial transaction is taking place, but no email is being sent or any other positive indication.</p>
  <p>The CiviCRM log is not very interesting and does nothing in response to the event. I guess it's failing before it even gets back there.</p>
  <p>The Apache log shows this:</p>
  <p><code>[Mon May 06 21:38:23.158374 2024] [proxy_fcgi:error] [pid 1683822:tid 140013131994816] [client 174.89.140.61:58238] AH01071: Got error 'PHP message: PHP Warning:  Undefined array key &quot;selfcancelxfer_time&quot; in /var/www/civicrmsite/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Event/BAO/Event.php on line 1172; PHP message: PHP Warning:  Undefined array key &quot;selfcancelxfer_time&quot; in /var/www/civicrmsite/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Event/BAO/Event.php on line 1173; PHP message: PHP Parse error:  syntax error, unexpected token &quot;&gt;&quot; in /var/www/civicrmsite/wordpress/wp-content/plugins/civicrm/civicrm/packages/Smarty/Smarty.class.php(2018) : eval()'d code on line 624', referer: https://civicrmsite/civicrm/event/register/?_qf_Confirm_display=true&amp;qfKey=CRMEventControllerRegistration4xuwhov9accg4kgs40cswkwo4wksk4kg44w8o0wsoswg4gog8s_7359</code></p>
  <p>I've reset all the system messages back to the defaults. The only one customized was the basic &quot;Invoice&quot; one anyway. Same error. I am also confused by the (2018) in brackets on <code>/var/www/civicrmsite/wordpress/wp-content/plugins/civicrm/civicrm/packages/Smarty/Smarty.class.php(2018)</code>
  There is no such file. If remove (2018) and then visit the line 624 reference I'm no wiser with a very simple if test inside a foreach loop:</p>
  <pre><code>    function append($tpl_var, $value=null, $merge=false)
      {
          if (is_array($tpl_var)) {
              // $tpl_var is an array, ignore $value
              foreach ($tpl_var as $_key =&gt; $_val) {
                  if ($_key != '') {          # this is line 624
  </code></pre>
  <p>presumably the &quot;unexpected token &quot;&gt;&quot;' mentioned in the Apache error log is coming through somewhere, but I haven't a clue where.</p>
  <p>I'm on CiviCRM 5.70.1 on WordPress 6.5.2 and PHP 8.2.13. I have kept the system on Smarty 2 for now. Could that have something to do with it?
  I can start to move the upgrades along, but I'd prefer to fix the problem first unless someone tells me it's a known problem that is fixed in a newer version.</p>
  <p>Anyone have any thoughts? Further diagnostics I could perform?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-05-06T23:22:01.060Z
Comments.Text: These are hard to find. The 2018 means line 2018, but all that tells you is it's an error. You said you reset the message templates, but the line 624 refers to line 624 in the compiled version of the message template. And if I had to guess it's referring to the ending `>` meaning it thinks the compiled template has an open control structure that hasn't been closed (e.g. an `if` or `foreach` or something). Ideally you'd be able to add some logging just before it throws the error, but I'm not sure where that is.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-05-07T07:50:32.677Z
Comments.Text: Might be worth checking out below post as could be the same error https://civicrm.stackexchange.com/questions/47973/event-registration-fails-with-an-error
Comments.UserDisplayName: RebeccaTregenna
Tags: <civievent><smarty>
Title: Event registration error on confirmation. Probably Smarty, but I'm not consciously using it
ThreadText: # Event registration error on confirmation. Probably Smarty, but I'm not consciously using it
  
  (Asked by: username_0 on 2024-05-06)
  
  I am having trouble with event registrations on an event that seemed to work fine a couple of months ago. The live event happened with no issues back in Jan and Feb. We've since re-activated the event as a gateway to access the videos. We changed the dates to keep it available and started taking registrations. I can't recall if we tested it then again or not.
  However, it is now crashing with "There has been a critical error on this website"
  The financial transaction is taking place, but no email is being sent or any other positive indication.
  The CiviCRM log is not very interesting and does nothing in response to the event. I guess it's failing before it even gets back there.
  The Apache log shows this:
  [Mon May 06 21:38:23.158374 2024] [proxy_fcgi:error] [pid 1683822:tid 140013131994816] [client 174.89.140.61:58238] AH01071: Got error 'PHP message: PHP Warning:  Undefined array key "selfcancelxfer_time" in /var/www/civicrmsite/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Event/BAO/Event.php on line 1172; PHP message: PHP Warning:  Undefined array key "selfcancelxfer_time" in /var/www/civicrmsite/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Event/BAO/Event.php on line 1173; PHP message: PHP Parse error:  syntax error, unexpected token ">" in /var/www/civicrmsite/wordpress/wp-content/plugins/civicrm/civicrm/packages/Smarty/Smarty.class.php(2018) : eval()'d code on line 624', referer: https://civicrmsite/civicrm/event/register/?_qf_Confirm_display=true&qfKey=CRMEventControllerRegistration4xuwhov9accg4kgs40cswkwo4wksk4kg44w8o0wsoswg4gog8s_7359
  I've reset all the system messages back to the defaults. The only one customized was the basic "Invoice" one anyway. Same error. I am also confused by the (2018) in brackets on /var/www/civicrmsite/wordpress/wp-content/plugins/civicrm/civicrm/packages/Smarty/Smarty.class.php(2018)
  There is no such file. If remove (2018) and then visit the line 624 reference I'm no wiser with a very simple if test inside a foreach loop:
      function append($tpl_var, $value=null, $merge=false)
      {
          if (is_array($tpl_var)) {
              // $tpl_var is an array, ignore $value
              foreach ($tpl_var as $_key => $_val) {
                  if ($_key != '') {          # this is line 624
  
  presumably the "unexpected token ">"' mentioned in the Apache error log is coming through somewhere, but I haven't a clue where.
  I'm on CiviCRM 5.70.1 on WordPress 6.5.2 and PHP 8.2.13. I have kept the system on Smarty 2 for now. Could that have something to do with it?
  I can start to move the upgrades along, but I'd prefer to fix the problem first unless someone tells me it's a known problem that is fixed in a newer version.
  Anyone have any thoughts? Further diagnostics I could perform?
  
  **Tags:** civievent, smarty
  
  > **Comments:**
  > **username_1**: These are hard to find. The 2018 means line 2018, but all that tells you is it's an error. You said you reset the message templates, but the line 624 refers to line 624 in the compiled version of the message template. And if I had to guess it's referring to the ending `>` meaning it thinks the compiled template has an open control structure that hasn't been closed (e.g. an `if` or `foreach` or something). Ideally you'd be able to add some logging just before it throws the error, but I'm not sure where that is.  
  > **username_2**: Might be worth checking out below post as could be the same error https://civicrm.stackexchange.com/questions/47973/event-registration-fails-with-an-error  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2024-05-07. Score: 1 | Accepted answer
  
  If you are on CiviCRM 5.70.x then it's a known issue which is fixed in the recent version. You can either apply the below patch and do db changes or upgrade CiviCRM to 5.72.x
  
  Patch file CRM/Event/DAO/Event.php
  
  diff --git a/CRM/Event/DAO/Event.php b/CRM/Event/DAO/Event.php
  index 32de78e3325c..de7379737b04 100644
  --- a/CRM/Event/DAO/Event.php
  +++ b/CRM/Event/DAO/Event.php
  @@ -6,7 +6,7 @@
    *
    * Generated from xml/schema/CRM/Event/Event.xml
    * DO NOT EDIT.  Generated by CRM_Core_CodeGen
  - * (GenCodeChecksum:d63c53d10f2e09895a19061ea9d51093)
  + * (GenCodeChecksum:193894c0362eb3c7360ad8245e303fcf)
    */
   
   /**
  @@ -542,7 +542,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
     /**
      * Number of hours prior to event start date to allow self-service cancellation or transfer.
      *
  -   * @var int|string|null
  +   * @var int|string
      *   (SQL type: int)
      *   Note that values will be retrieved from the database as a string.
      */
  @@ -1994,6 +1994,7 @@ public static function &fields() {
             'type' => CRM_Utils_Type::T_INT,
             'title' => ts('Self-service Cancellation or Transfer Time'),
             'description' => ts('Number of hours prior to event start date to allow self-service cancellation or transfer.'),
  +          'required' => TRUE,
             'usage' => [
               'import' => FALSE,
               'export' => FALSE,
  
  
  Run below query
  
  UPDATE civicrm_event SET selfcancelxfer_time = 0 WHERE selfcancelxfer_time IS NULL;
  
  ALTER TABLE civicrm_event MODIFY COLUMN selfcancelxfer_time int(11) DEFAULT 0 NOT NULL COMMENT 'Number of hours prior to event start date to allow self-service cancellation or transfer.';
  
  
  
  
  Clear CiviCRM cache
  
  HTH
  Pradeep
  
  
  ---
  
  