Answers.Body: <h1>TL;DR</h1>
  
  <p>Go to <code>&lt;site&gt;/sites/all/modules/civicrm/CRM/Price/BAO/PriceField.php</code> line 179</p>
  
  <p>And to the following condition:</p>
  
  <pre><code>elseif (!empty($optionsIds)) {
  </code></pre>
  
  <p>Add another condition for verifying that the <strong><code>id</code> exists and is not <code>null</code></strong>, i.e. you may replace it with:</p>
  
  <pre><code>elseif (!empty($optionsIds) &amp;&amp; isset($optionsIds['id'])) {
  </code></pre>
  
  <hr/>
  
  <h1>Explanation</h1>
  
  <p>This simple resolution was due to the investigative work of <a href="https://issues.civicrm.org/jira/browse/CRM-20729?focusedCommentId=104938&amp;page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-104938" rel="nofollow noreferrer">Favio Manriquez (JIRA)</a> where he explained the following:</p>
  
  <blockquote>
    <p>I was able to confirm this behavior.  When debugging, if you print a
    stack trace at the Fatal Error location, you don't get a lot of
    information.  By stepping through the code, I arrived at
    <code>CRM_Price_BAO_PriceField::create()</code>.  I'll try to explain what is
    causing this error:</p>
    
    <ul>
    <li>When you go to the configure screen for an Event, and then add a new fee (this doesn't happen for events that use price sets), the for
    loop goes through all fees, and updates or creates them as necessary. 
    However, on the first if branch, the <code>$optionsIds</code> variable is set, and
    it is used again on the <code>elseif</code> branch at line 179 !!</li>
    <li>It's only when you add a new Fee, that this <code>elseif</code> branch causes problems, because the last id in <code>$optionsIds</code> is <code>NULL</code> (for the new
    price that was created on first branch).  This causes a fatal error
    via <code>CRM_Core_Error::fatal()</code> which forces a transaction rollback.</li>
    </ul>
    
    <p>This code change was introduced on this <a href="https://github.com/civicrm/civicrm-core/commit/1019b2fe8e5e506f34cf338d6e4e77f601b408c4#diff-03753662a69aab9f4543e6a8492d2e64R173" rel="nofollow noreferrer">commit</a> for <a href="https://issues.civicrm.org/jira/browse/CRM-19517" rel="nofollow noreferrer">CRM-19517</a>, but
    on previous versions the <code>elseif</code> branch is not present, so I'm not
    exactly sure why this code is needed.</p>
    
    <p>I could add an easy PR to check if the id is <code>null</code>, but since this is
    related to <a href="https://issues.civicrm.org/jira/browse/CRM-19517" rel="nofollow noreferrer">CRM-19517</a>, I would like to get more insight first.</p>
  </blockquote>
  
  <p>As Favio explained, the <code>null</code> check is necessary because inside the <code>elseif</code> the value of <code>$optionsIds['id']</code> is used:</p>
  
  <pre><code> $optionsLoad = civicrm_api3('price_field_value', 'get', array('id' =&gt; $optionsIds['id']));
  </code></pre>
  
  <ol>
  <li><p>If <code>$optionsIds['id']</code> is <code>null</code>, invoking:</p>
  
  <p><code>$options = $optionsLoad['values'][$optionsIds['id']]</code></p>
  
  <p>Would be equivalent to invoke:</p>
  
  <p><code>$options = $optionsLoad['values'][null]</code></p>
  
  <p>Which would only trigger an "undefined index" notice (not stopping the execution).</p></li>
  <li>This would in turn provide <code>null</code> in <code>$options</code>, which are used later in:
    <code>CRM_Price_BAO_PriceFieldValue::create($options, $optionsIds);</code></li>
  <li><p>Therefore the <code>create</code> is attempted with invalid options and that is why the <em>Stacktrace</em> starts with:</p>
  
  <blockquote>
    <p>CRM/Price/BAO/PriceFieldValue.php(65): <code>CRM_Core_DAO::getFieldValue("CRM_Price_BAO_PriceFieldValue", NULL, "price_field_id")</code></p>
  </blockquote></li>
  </ol>
  
  <h2>Why the value is <code>null</code> there?</h2>
  
  <p>If we look back to line 99 of <code>PriceField.php</code>:</p>
  
  <pre><code>  $fieldOptions = civicrm_api3('price_field_value', 'get', array(
      'price_field_id' =&gt; $priceField-&gt;id,
      'sequential' =&gt; 1,
    ));
  </code></pre>
  
  <p>And think of the action we, as users, are trying to perform, i.e. editing/adding a new Fee field, the <code>$fieldOptions['values']</code> will not contain this new field.</p>
  
  <p>Thus the next and only <code>foreach</code> that assigns the options to <code>$optionsIds</code> prior to that <code>elseif</code> block:</p>
  
  <pre><code>foreach ($fieldOptions['values'] as $option) {
    $optionsIds['id'] = $option['id'];
    ...
  }
  </code></pre>
  
  <p>Will not not have an iteration for this new field. At the point where <code>civicrm_api3('price_field_value'</code> is invoked to get the field associated to an id, since the new field's id does not exist, <code>null</code> will show up.</p>
  
  <p>Therefore, this particular <code>elseif</code> block should only be run only if the field has an id already associated to it, the <code>!empty($optionsIds)</code> condition only prevented part of possible failures in this sense.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-12T11:42:47.343Z
Answers.LastActivityDate: 2017-07-12T11:42:47.343Z
Answers.UserDisplayName: Armfoot
Answers.Body: <p>It is a bug (see <a href="https://issues.civicrm.org/jira/browse/CRM-20729" rel="nofollow noreferrer">https://issues.civicrm.org/jira/browse/CRM-20729</a>) and it is fixed in 4.7.22. If an upgrade is not an option you can manually apply the patch <a href="https://issues.civicrm.org/jira/browse/CRM-20729" rel="nofollow noreferrer">https://issues.civicrm.org/jira/browse/CRM-20729</a> .</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-10T12:52:54.520Z
Answers.LastActivityDate: 2017-11-10T12:52:54.520Z
Answers.UserDisplayName: Kainuk - CiviCooP
Answers.Body: <p>@sovereign108 The <a href="https://issues.civicrm.org/jira/browse/CRM-20729" rel="nofollow noreferrer">issue on Jira has been updated with a comment</a> by @favrik.  The workaround for now is to use price sets, as that is not impacted. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-22T14:50:46.537Z
Answers.LastActivityDate: 2017-06-22T14:50:46.537Z
Answers.UserDisplayName: themak
Answers.Body: <p>This issue has been fixed at <a href="https://github.com/civicrm/civicrm-core/pull/10597/files" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-core/pull/10597/files</a> for CRM issue <a href="https://issues.civicrm.org/jira/projects/CRM/issues/CRM-20760" rel="nofollow noreferrer">https://issues.civicrm.org/jira/projects/CRM/issues/CRM-20760</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-29T15:23:09.737Z
Answers.LastActivityDate: 2017-12-29T15:23:09.737Z
Answers.UserDisplayName: FullStack-Dev
Body: <p>I have created an event with several payment options and it works properly with no issues. However, when adding a new fee (there are 5 at the moment that works), It doesn't get saved and the loader spinner just spins forever.</p>
  
  <p>Underneath, when inspecting the network when the form is submitted, I get this</p>
  
  <blockquote>
    <p>{status: "fatal",…} content : "Sorry but we are not
    able to provide this at the moment." crmMessages : [{,…}] 0 :
    {,…} options : null text : "We experienced an unexpected error. Please
    post a detailed description and the backtrace on the CiviCRM forums:
    <a href="http://forum.civicrm.org/" rel="nofollow noreferrer">http://forum.civicrm.org/</a>" title : "Sorry an error occurred" type :
    "error" status : "fatal" title : "Configure Event - B1
    Course" userContext : "/civicrm/event/manage?reset=1"</p>
  </blockquote>
  
  <p>In the error logs, this detailed response is outputted:</p>
  
  <pre><code>There was a CiviCRM error at ISKCON London Ltd.
  Date: 2017-06-11T12:52:30+01:00
  
  
  
  ***ERROR***
  message:            
  code:                
  
  ***LAST ERROR***
  
  
  ***LOGGED IN USER***
  contact_id:         2
  display_name:       Mr. Aashish Sharma
  email_id:           
  email:              
  id:                 2
  
  REMOTE_ADDR: 82.47.150.10
  HTTP_USER_AGENT: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36
  
  
  ***SERVER***
  PATH:               /usr/local/bin:/usr/bin:/bin
  REDIRECT_STATUS:    200
  UNIQUE_ID:          WT0u-sMI3iEAABks7HYAAABJ
  TZ:                 Europe/Sofia
  OMP_THREAD_LIMIT:   1
  HTTP_AUTHORIZATION: 
  HTTPS:              on
  SSL_TLS_SNI:        rldb.info
  HTTP_HOST:          rldb.info
  HTTP_CONNECTION:    keep-alive
  CONTENT_LENGTH:     8826
  HTTP_ORIGIN:        https://rldb.info
  HTTP_USER_AGENT:    Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36
  CONTENT_TYPE:       multipart/form-data; boundary=----WebKitFormBoundaryxVzJBFAoBtR543ba
  HTTP_ACCEPT:        application/json, text/javascript, */*; q=0.01
  HTTP_X_REQUESTED_WITH:XMLHttpRequest
  HTTP_DNT:           1
  HTTP_REFERER:       https://rldb.info/civicrm/event/manage/fee?reset=1&amp;action=update&amp;id=48
  HTTP_ACCEPT_ENCODING:gzip, deflate, br
  HTTP_ACCEPT_LANGUAGE:en-GB,en-US;q=0.8,en;q=0.6
  HTTP_COOKIE:        SESSfdfbbafa8321456c2612c2aa8f3eb683=UM-Iryeyj-zQpNIzlWLda-cQEovuWWEBLfp_RW-LN-E; Drupal.tableDrag.showWeight=0; SSESSfdfbbafa8321456c2612c2aa8f3eb683=cOvpS0HYROxslVL4qewR4nCYYYg8VRpQZUmtSDA2Oik; has_js=1
  SERVER_SIGNATURE:   
  SERVER_SOFTWARE:    Apache
  SERVER_NAME:        rldb.info
  SERVER_ADDR:        195.8.222.33
  SERVER_PORT:        443
  REMOTE_ADDR:        82.47.150.10
  DOCUMENT_ROOT:      /home/rldb/www/www
  REQUEST_SCHEME:     https
  CONTEXT_PREFIX:     
  CONTEXT_DOCUMENT_ROOT:/home/rldb/www/www
  SERVER_ADMIN:       admin@rldb.info
  SCRIPT_FILENAME:    /home/rldb/www/www/index.php
  REMOTE_PORT:        60253
  REDIRECT_URL:       /civicrm/event/manage/fee
  REDIRECT_QUERY_STRING:action=update&amp;id=48&amp;component=event&amp;qfKey=8597fbacd761cbef1573e2c09b4cf85a_3956&amp;snippet=json
  GATEWAY_INTERFACE:  CGI/1.1
  SERVER_PROTOCOL:    HTTP/1.1
  REQUEST_METHOD:     POST
  QUERY_STRING:       action=update&amp;id=48&amp;component=event&amp;qfKey=8597fbacd761cbef1573e2c09b4cf85a_3956&amp;snippet=json
  REQUEST_URI:        /civicrm/event/manage/fee?action=update&amp;id=48&amp;component=event&amp;qfKey=8597fbacd761cbef1573e2c09b4cf85a_3956&amp;snippet=json
  SCRIPT_NAME:        /index.php
  PHP_SELF:           /index.php
  REQUEST_TIME_FLOAT: 1497181950.1148
  REQUEST_TIME:       1497181950
  argv:               Array
  (
      [0] =&gt; action=update&amp;id=48&amp;component=event&amp;qfKey=8597fbacd761cbef1573e2c09b4cf85a_3956&amp;snippet=json
  )
  
  argc:               1
  
  
  
  ***BACKTRACE***
  #0 /home/rldb/www/www/sites/default/files/civicrm/ext/ca.bidon.reporterror/reporterror.php(251): reporterror_civicrm_generatereport("ISKCON London Ltd", (Array:2), NULL, (Array:0))
  #1 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Core/Error.php(365): reporterror_civicrm_handler((Array:2))
  #2 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Core/DAO.php(1070): CRM_Core_Error::fatal()
  #3 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Price/BAO/PriceFieldValue.php(65): CRM_Core_DAO::getFieldValue("CRM_Price_BAO_PriceFieldValue", NULL, "price_field_id")
  #4 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Price/BAO/PriceFieldValue.php(127): CRM_Price_BAO_PriceFieldValue::add((Array:3), (Array:1))
  #5 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Price/BAO/PriceField.php(184): CRM_Price_BAO_PriceFieldValue::create((Array:3), (Array:1))
  #6 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Event/Form/ManageEvent/Fee.php(670): CRM_Price_BAO_PriceField::create((Array:9))
  #7 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Core/Form.php(447): CRM_Event_Form_ManageEvent_Fee-&gt;postProcess()
  #8 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php(169): CRM_Core_Form-&gt;mainProcess()
  #9 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php(136): CRM_Core_QuickForm_Action_Upload-&gt;realPerform(Object(CRM_Event_Form_ManageEvent_Fee), "upload")
  #10 /home/rldb/www/www/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Upload-&gt;perform(Object(CRM_Event_Form_ManageEvent_Fee), "upload")
  #11 /home/rldb/www/www/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller-&gt;handle(Object(CRM_Event_Form_ManageEvent_Fee), "upload")
  #12 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Core/Controller.php(351): HTML_QuickForm_Page-&gt;handle("upload")
  #13 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Utils/Wrapper.php(113): CRM_Core_Controller-&gt;run()
  #14 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Core/Invoke.php(284): CRM_Utils_Wrapper-&gt;run("CRM_Event_Form_ManageEvent_Fee", "Event Fees", NULL)
  #15 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:14))
  #16 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:4))
  #17 /home/rldb/www/www/sites/all/modules/civicrm/drupal/civicrm.module(448): CRM_Core_Invoke::invoke((Array:4))
  #18 [internal function](): civicrm_invoke("event", "manage", "fee")
  #19 /home/rldb/www/www/includes/menu.inc(527): call_user_func_array("civicrm_invoke", (Array:3))
  #20 /home/rldb/www/www/index.php(21): menu_execute_active_handler()
  #21 {main}
  
  
  ***POST***
  qfKey:              8597fbacd761cbef1573e2c09b4cf85a_3956
  entryURL:           https://rldb.info/civicrm/event/manage/fee?reset=1&amp;amp;action=update&amp;amp;id=48&amp;amp;component=event&amp;amp;qfKey=8597fbacd761cbef1573e2c09b4cf85a_3956
  price_field_id:     168
  price_field_value:  Array
  (
      [1] =&gt; 537
      [2] =&gt; 538
      [3] =&gt; 539
      [4] =&gt; 540
      [5] =&gt; 541
      [6] =&gt; 
      [7] =&gt; 
      [8] =&gt; 
      [9] =&gt; 
      [10] =&gt; 
      [11] =&gt; 
  )
  
  discount_price_set: Array
  (
      [1] =&gt; 
      [2] =&gt; 
      [3] =&gt; 
      [4] =&gt; 
      [5] =&gt; 
      [6] =&gt; 
  )
  
  cancelURL:          /civicrm/event/manage?reset=1
  _qf_default:        Fee:upload
  MAX_FILE_SIZE:      20971520
  is_template:        0
  is_monetary:        1
  currency:           GBP
  payment_processor:  1
  pay_later_text:     I will send payment by cheque
  pay_later_receipt:  
  fee_label:          Event Fee(s)
  financial_type_id:  9
  price_set_id:       
  label:              Array
  (
      [1] =&gt; For all 6 Units of Bhakti Sastri
      [2] =&gt; If spouses/partners do course together. cost per participant
      [3] =&gt; Cost for One Unit
      [4] =&gt; For Temple Asrama
      [5] =&gt; Others - pay in 2 instalments
      [6] =&gt; test
      [7] =&gt; 
      [8] =&gt; 
      [9] =&gt; 
      [10] =&gt; 
  )
  
  value:              Array
  (
      [1] =&gt; 275.00
      [2] =&gt; 250.00
      [3] =&gt; 50.00
      [4] =&gt; 0.00
      [5] =&gt; 137.50
      [6] =&gt; 50.00
      [7] =&gt; 
      [8] =&gt; 
      [9] =&gt; 
      [10] =&gt; 
  )
  
  default:            1
  discount_name:      Array
  (
      [1] =&gt; 
      [2] =&gt; 
      [3] =&gt; 
      [4] =&gt; 
      [5] =&gt; 
  )
  
  discount_start_date:Array
  (
      [1] =&gt; 
      [2] =&gt; 
      [3] =&gt; 
      [4] =&gt; 
      [5] =&gt; 
  )
  
  discount_start_date_1_display_593d2e777d8ea:
  discount_end_date:  Array
  (
      [1] =&gt; 
      [2] =&gt; 
      [3] =&gt; 
      [4] =&gt; 
      [5] =&gt; 
  )
  
  discount_end_date_1_display_593d2e777ef79:
  discount_start_date_2_display_593d2e77805c8:
  discount_end_date_2_display_593d2e7781c84:
  discount_start_date_3_display_593d2e778357c:
  discount_end_date_3_display_593d2e7784b4b:
  discount_start_date_4_display_593d2e7786147:
  discount_end_date_4_display_593d2e7787771:
  discount_start_date_5_display_593d2e7788e1e:
  discount_end_date_5_display_593d2e778a52b:
  _qf_Fee_upload:     Save
  </code></pre>
  
  <p>Any help would be much appreciated!</p>
  
  <p>Thanks</p>
  
  <p>Edit 1:
  Upgrading CiviCRM from 4.7.19 to 4.7.20 did not resolve the issue.</p>
  
  <p>Edit 2:
  When creating a new event from scratch, I can add as many fee options as I want. But, if I save and then add a new fee, then these errors occur and I can't save.</p>
  
  <p>Any help?</p>
  
  <p>Edit 3:
  If I add a new fee (after it has been saved) and instead click on 'save and done', this is th emessage:</p>
  
  <blockquote>
    <p>Fatal error: Uncaught CRM_Core_Exception: [0: Transaction integrity
    error: Expected to find active frame thrown in
    /home/rldb/www/www/sites/all/modules/civicrm/Civi/Core/Transaction/Manager.php
    on line 107</p>
  </blockquote>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-12T19:05:26.787Z
Comments.Text: I am also experiencing this same issue.  4.7.19
  
  Fatal error: Uncaught CRM_Core_Exception: [0: Transaction integrity error: Expected to find active frame thrown in /home/tarabnyc/public_html/wp-content/plugins/civicrm/civicrm/Civi/Core/Transaction/Manager.php on line 107
Comments.UserDisplayName: themak
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-14T20:22:37.320Z
Comments.Text: Hi Sovereign, look like a bug. Can you reproduce it on the http://dmaster.demo.civicrm.org/ site.
Comments.UserDisplayName: Kainuk - CiviCooP
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-15T20:50:39.953Z
Comments.Text: @kanuk I am able to replicate it on your demo.
  
  I reported the bug at https://issues.civicrm.org/jira/browse/CRM-20729?jql=resolution%20%3D%20Unresolved%20AND%20reporter%20%3D%20currentUser()
  
  The only error I get is  Sorry but we are not able to provide this at the moment. Return to home page.
Comments.UserDisplayName: themak
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-20T21:41:11.807Z
Comments.Text: @sovereign108 were you ever able to find a fix?
Comments.UserDisplayName: themak
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-21T22:33:40.087Z
Comments.Text: @themak unfortunately not. I just tried to avoid the scenario.
Comments.UserDisplayName: Sovereign108
Tags: <civievent>
Title: Can't Add a New Fee to an Existing Event in 4.7.20
ThreadText: # Can't Add a New Fee to an Existing Event in 4.7.20
  
  (Asked by: username_0 on 2017-06-11)
  
  I have created an event with several payment options and it works properly with no issues. However, when adding a new fee (there are 5 at the moment that works), It doesn't get saved and the loader spinner just spins forever.
  
  Underneath, when inspecting the network when the form is submitted, I get this
  
  > {status: "fatal",…} content : "Sorry but we are not
  > able to provide this at the moment." crmMessages : [{,…}] 0 :
  > {,…} options : null text : "We experienced an unexpected error. Please
  > post a detailed description and the backtrace on the CiviCRM forums:
  > <http://forum.civicrm.org/>" title : "Sorry an error occurred" type :
  > "error" status : "fatal" title : "Configure Event - B1
  > Course" userContext : "/civicrm/event/manage?reset=1"
  
  In the error logs, this detailed response is outputted:
  
  ```
  There was a CiviCRM error at ISKCON London Ltd.
  Date: 2017-06-11T12:52:30+01:00
  
  ***ERROR***
  message:            
  code:                
  
  ***LAST ERROR***
  
  ***LOGGED IN USER***
  contact_id:         2
  display_name:       Mr. Aashish Sharma
  email_id:           
  email:              
  id:                 2
  
  REMOTE_ADDR: 82.47.150.10
  HTTP_USER_AGENT: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36
  
  ***SERVER***
  PATH:               /usr/local/bin:/usr/bin:/bin
  REDIRECT_STATUS:    200
  UNIQUE_ID:          WT0u-sMI3iEAABks7HYAAABJ
  TZ:                 Europe/Sofia
  OMP_THREAD_LIMIT:   1
  HTTP_AUTHORIZATION: 
  HTTPS:              on
  SSL_TLS_SNI:        rldb.info
  HTTP_HOST:          rldb.info
  HTTP_CONNECTION:    keep-alive
  CONTENT_LENGTH:     8826
  HTTP_ORIGIN:        https://rldb.info
  HTTP_USER_AGENT:    Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36
  CONTENT_TYPE:       multipart/form-data; boundary=----WebKitFormBoundaryxVzJBFAoBtR543ba
  HTTP_ACCEPT:        application/json, text/javascript, */*; q=0.01
  HTTP_X_REQUESTED_WITH:XMLHttpRequest
  HTTP_DNT:           1
  HTTP_REFERER:       https://rldb.info/civicrm/event/manage/fee?reset=1&action=update&id=48
  HTTP_ACCEPT_ENCODING:gzip, deflate, br
  HTTP_ACCEPT_LANGUAGE:en-GB,en-US;q=0.8,en;q=0.6
  HTTP_COOKIE:        SESSfdfbbafa8321456c2612c2aa8f3eb683=UM-Iryeyj-zQpNIzlWLda-cQEovuWWEBLfp_RW-LN-E; Drupal.tableDrag.showWeight=0; SSESSfdfbbafa8321456c2612c2aa8f3eb683=cOvpS0HYROxslVL4qewR4nCYYYg8VRpQZUmtSDA2Oik; has_js=1
  SERVER_SIGNATURE:   
  SERVER_SOFTWARE:    Apache
  SERVER_NAME:        rldb.info
  SERVER_ADDR:        195.8.222.33
  SERVER_PORT:        443
  REMOTE_ADDR:        82.47.150.10
  DOCUMENT_ROOT:      /home/rldb/www/www
  REQUEST_SCHEME:     https
  CONTEXT_PREFIX:     
  CONTEXT_DOCUMENT_ROOT:/home/rldb/www/www
  SERVER_ADMIN:       admin@rldb.info
  SCRIPT_FILENAME:    /home/rldb/www/www/index.php
  REMOTE_PORT:        60253
  REDIRECT_URL:       /civicrm/event/manage/fee
  REDIRECT_QUERY_STRING:action=update&id=48&component=event&qfKey=8597fbacd761cbef1573e2c09b4cf85a_3956&snippet=json
  GATEWAY_INTERFACE:  CGI/1.1
  SERVER_PROTOCOL:    HTTP/1.1
  REQUEST_METHOD:     POST
  QUERY_STRING:       action=update&id=48&component=event&qfKey=8597fbacd761cbef1573e2c09b4cf85a_3956&snippet=json
  REQUEST_URI:        /civicrm/event/manage/fee?action=update&id=48&component=event&qfKey=8597fbacd761cbef1573e2c09b4cf85a_3956&snippet=json
  SCRIPT_NAME:        /index.php
  PHP_SELF:           /index.php
  REQUEST_TIME_FLOAT: 1497181950.1148
  REQUEST_TIME:       1497181950
  argv:               Array
  (
      [0] => action=update&id=48&component=event&qfKey=8597fbacd761cbef1573e2c09b4cf85a_3956&snippet=json
  )
  
  argc:               1
  
  ***BACKTRACE***
  #0 /home/rldb/www/www/sites/default/files/civicrm/ext/ca.bidon.reporterror/reporterror.php(251): reporterror_civicrm_generatereport("ISKCON London Ltd", (Array:2), NULL, (Array:0))
  #1 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Core/Error.php(365): reporterror_civicrm_handler((Array:2))
  #2 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Core/DAO.php(1070): CRM_Core_Error::fatal()
  #3 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Price/BAO/PriceFieldValue.php(65): CRM_Core_DAO::getFieldValue("CRM_Price_BAO_PriceFieldValue", NULL, "price_field_id")
  #4 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Price/BAO/PriceFieldValue.php(127): CRM_Price_BAO_PriceFieldValue::add((Array:3), (Array:1))
  #5 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Price/BAO/PriceField.php(184): CRM_Price_BAO_PriceFieldValue::create((Array:3), (Array:1))
  #6 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Event/Form/ManageEvent/Fee.php(670): CRM_Price_BAO_PriceField::create((Array:9))
  #7 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Core/Form.php(447): CRM_Event_Form_ManageEvent_Fee->postProcess()
  #8 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php(169): CRM_Core_Form->mainProcess()
  #9 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php(136): CRM_Core_QuickForm_Action_Upload->realPerform(Object(CRM_Event_Form_ManageEvent_Fee), "upload")
  #10 /home/rldb/www/www/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Upload->perform(Object(CRM_Event_Form_ManageEvent_Fee), "upload")
  #11 /home/rldb/www/www/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Event_Form_ManageEvent_Fee), "upload")
  #12 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Core/Controller.php(351): HTML_QuickForm_Page->handle("upload")
  #13 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Utils/Wrapper.php(113): CRM_Core_Controller->run()
  #14 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Core/Invoke.php(284): CRM_Utils_Wrapper->run("CRM_Event_Form_ManageEvent_Fee", "Event Fees", NULL)
  #15 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:14))
  #16 /home/rldb/www/www/sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:4))
  #17 /home/rldb/www/www/sites/all/modules/civicrm/drupal/civicrm.module(448): CRM_Core_Invoke::invoke((Array:4))
  #18 [internal function](): civicrm_invoke("event", "manage", "fee")
  #19 /home/rldb/www/www/includes/menu.inc(527): call_user_func_array("civicrm_invoke", (Array:3))
  #20 /home/rldb/www/www/index.php(21): menu_execute_active_handler()
  #21 {main}
  
  ***POST***
  qfKey:              8597fbacd761cbef1573e2c09b4cf85a_3956
  entryURL:           https://rldb.info/civicrm/event/manage/fee?reset=1&amp;action=update&amp;id=48&amp;component=event&amp;qfKey=8597fbacd761cbef1573e2c09b4cf85a_3956
  price_field_id:     168
  price_field_value:  Array
  (
      [1] => 537
      [2] => 538
      [3] => 539
      [4] => 540
      [5] => 541
      [6] => 
      [7] => 
      [8] => 
      [9] => 
      [10] => 
      [11] => 
  )
  
  discount_price_set: Array
  (
      [1] => 
      [2] => 
      [3] => 
      [4] => 
      [5] => 
      [6] => 
  )
  
  cancelURL:          /civicrm/event/manage?reset=1
  _qf_default:        Fee:upload
  MAX_FILE_SIZE:      20971520
  is_template:        0
  is_monetary:        1
  currency:           GBP
  payment_processor:  1
  pay_later_text:     I will send payment by cheque
  pay_later_receipt:  
  fee_label:          Event Fee(s)
  financial_type_id:  9
  price_set_id:       
  label:              Array
  (
      [1] => For all 6 Units of Bhakti Sastri
      [2] => If spouses/partners do course together. cost per participant
      [3] => Cost for One Unit
      [4] => For Temple Asrama
      [5] => Others - pay in 2 instalments
      [6] => test
      [7] => 
      [8] => 
      [9] => 
      [10] => 
  )
  
  value:              Array
  (
      [1] => 275.00
      [2] => 250.00
      [3] => 50.00
      [4] => 0.00
      [5] => 137.50
      [6] => 50.00
      [7] => 
      [8] => 
      [9] => 
      [10] => 
  )
  
  default:            1
  discount_name:      Array
  (
      [1] => 
      [2] => 
      [3] => 
      [4] => 
      [5] => 
  )
  
  discount_start_date:Array
  (
      [1] => 
      [2] => 
      [3] => 
      [4] => 
      [5] => 
  )
  
  discount_start_date_1_display_593d2e777d8ea:
  discount_end_date:  Array
  (
      [1] => 
      [2] => 
      [3] => 
      [4] => 
      [5] => 
  )
  
  discount_end_date_1_display_593d2e777ef79:
  discount_start_date_2_display_593d2e77805c8:
  discount_end_date_2_display_593d2e7781c84:
  discount_start_date_3_display_593d2e778357c:
  discount_end_date_3_display_593d2e7784b4b:
  discount_start_date_4_display_593d2e7786147:
  discount_end_date_4_display_593d2e7787771:
  discount_start_date_5_display_593d2e7788e1e:
  discount_end_date_5_display_593d2e778a52b:
  _qf_Fee_upload:     Save
  
  ```
  
  Any help would be much appreciated!
  
  Thanks
  
  Edit 1:
  Upgrading CiviCRM from 4.7.19 to 4.7.20 did not resolve the issue.
  
  Edit 2:
  When creating a new event from scratch, I can add as many fee options as I want. But, if I save and then add a new fee, then these errors occur and I can't save.
  
  Any help?
  
  Edit 3:
  If I add a new fee (after it has been saved) and instead click on 'save and done', this is th emessage:
  
  > Fatal error: Uncaught CRM\_Core\_Exception: [0: Transaction integrity
  > error: Expected to find active frame thrown in
  > /home/rldb/www/www/sites/all/modules/civicrm/Civi/Core/Transaction/Manager.php
  > on line 107
  
  **Tags:** civievent
  
  > **Comments:**
  > **username_1**: I am also experiencing this same issue.  4.7.19  Fatal error: Uncaught CRM_Core_Exception: [0: Transaction integrity error: Expected to find active frame thrown in /home/tarabnyc/public_html/wp-content/plugins/civicrm/civicrm/Civi/Core/Transaction/Manager.php on line 107  
  > **username_2**: Hi Sovereign, look like a bug. Can you reproduce it on the http://dmaster.demo.civicrm.org/ site.  
  > **username_1**: @kanuk I am able to replicate it on your demo.  I reported the bug at https://issues.civicrm.org/jira/browse/CRM-20729?jql=resolution%20%3D%20Unresolved%20AND%20reporter%20%3D%20currentUser()  The only error I get is  Sorry but we are not able to provide this at the moment. Return to home page.  
  > **username_1**: @username_0 were you ever able to find a fix?  
  > **username_0**: @username_1 unfortunately not. I just tried to avoid the scenario.  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_3 on 2017-07-12. Score: 1
  
  # TL;DR
  
  Go to `<site>/sites/all/modules/civicrm/CRM/Price/BAO/PriceField.php` line 179
  
  And to the following condition:
  
  ```
  elseif (!empty($optionsIds)) {
  
  ```
  
  Add another condition for verifying that the **`id` exists and is not `null`**, i.e. you may replace it with:
  
  ```
  elseif (!empty($optionsIds) && isset($optionsIds['id'])) {
  
  ```
  
  ---
  
  # Explanation
  
  This simple resolution was due to the investigative work of [Favio Manriquez (JIRA)](https://issues.civicrm.org/jira/browse/CRM-20729?focusedCommentId=104938&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-104938) where he explained the following:
  
  > I was able to confirm this behavior. When debugging, if you print a
  > stack trace at the Fatal Error location, you don't get a lot of
  > information. By stepping through the code, I arrived at
  > `CRM_Price_BAO_PriceField::create()`. I'll try to explain what is
  > causing this error:
  >
  > * When you go to the configure screen for an Event, and then add a new fee (this doesn't happen for events that use price sets), the for
  >   loop goes through all fees, and updates or creates them as necessary.
  >   However, on the first if branch, the `$optionsIds` variable is set, and
  >   it is used again on the `elseif` branch at line 179 !!
  > * It's only when you add a new Fee, that this `elseif` branch causes problems, because the last id in `$optionsIds` is `NULL` (for the new
  >   price that was created on first branch). This causes a fatal error
  >   via `CRM_Core_Error::fatal()` which forces a transaction rollback.
  >
  > This code change was introduced on this [commit](https://github.com/civicrm/civicrm-core/commit/1019b2fe8e5e506f34cf338d6e4e77f601b408c4#diff-03753662a69aab9f4543e6a8492d2e64R173) for [CRM-19517](https://issues.civicrm.org/jira/browse/CRM-19517), but
  > on previous versions the `elseif` branch is not present, so I'm not
  > exactly sure why this code is needed.
  >
  > I could add an easy PR to check if the id is `null`, but since this is
  > related to [CRM-19517](https://issues.civicrm.org/jira/browse/CRM-19517), I would like to get more insight first.
  
  As Favio explained, the `null` check is necessary because inside the `elseif` the value of `$optionsIds['id']` is used:
  
  ```
   $optionsLoad = civicrm_api3('price_field_value', 'get', array('id' => $optionsIds['id']));
  
  ```
  
  1. If `$optionsIds['id']` is `null`, invoking:
  
     `$options = $optionsLoad['values'][$optionsIds['id']]`
  
     Would be equivalent to invoke:
  
     `$options = $optionsLoad['values'][null]`
  
     Which would only trigger an "undefined index" notice (not stopping the execution).
  2. This would in turn provide `null` in `$options`, which are used later in:
     `CRM_Price_BAO_PriceFieldValue::create($options, $optionsIds);`
  3. Therefore the `create` is attempted with invalid options and that is why the *Stacktrace* starts with:
  
     > CRM/Price/BAO/PriceFieldValue.php(65): `CRM_Core_DAO::getFieldValue("CRM_Price_BAO_PriceFieldValue", NULL, "price_field_id")`
  
  ## Why the value is `null` there?
  
  If we look back to line 99 of `PriceField.php`:
  
  ```
    $fieldOptions = civicrm_api3('price_field_value', 'get', array(
      'price_field_id' => $priceField->id,
      'sequential' => 1,
    ));
  
  ```
  
  And think of the action we, as users, are trying to perform, i.e. editing/adding a new Fee field, the `$fieldOptions['values']` will not contain this new field.
  
  Thus the next and only `foreach` that assigns the options to `$optionsIds` prior to that `elseif` block:
  
  ```
  foreach ($fieldOptions['values'] as $option) {
    $optionsIds['id'] = $option['id'];
    ...
  }
  
  ```
  
  Will not not have an iteration for this new field. At the point where `civicrm_api3('price_field_value'` is invoked to get the field associated to an id, since the new field's id does not exist, `null` will show up.
  
  Therefore, this particular `elseif` block should only be run only if the field has an id already associated to it, the `!empty($optionsIds)` condition only prevented part of possible failures in this sense.
  
  
  ---
  
  ### Answer by username_2 on 2017-11-10. Score: 1
  
  It is a bug (see <https://issues.civicrm.org/jira/browse/CRM-20729>) and it is fixed in 4.7.22. If an upgrade is not an option you can manually apply the patch <https://issues.civicrm.org/jira/browse/CRM-20729> .
  
  
  ---
  
  ### Answer by username_1 on 2017-06-22. Score: 0
  
  @username_0 The [issue on Jira has been updated with a comment](https://issues.civicrm.org/jira/browse/CRM-20729) by @favrik. The workaround for now is to use price sets, as that is not impacted.
  
  
  ---
  
  ### Answer by username_4 on 2017-12-29. Score: 0
  
  This issue has been fixed at <https://github.com/civicrm/civicrm-core/pull/10597/files> for CRM issue <https://issues.civicrm.org/jira/projects/CRM/issues/CRM-20760>
  
  
  ---
  
  