Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Critical
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.7.24, 4.7.27, 4.7.28
-
Fix Version/s: 4.7.30
-
Component/s: CiviEvent, CiviMember
-
Labels:
-
Versioning Impact:Patch (backwards-compatible bug fixes)
-
Documentation Required?:None
-
Funding Source:Needs Funding
-
Verified?:Yes
-
How it works currently:There are several ways (see description) that fatal errors appear when editing event registrations or memberships for the second time.
-
How it should work:You should be able to edit membership types or event selections as many times as you like.
-
Acceptance Criteria:Work through those three scenarios above for events plus the scenario for memberships, both with with increasing and decreasing prices. There should be no errors no matter how many changes you make.
Description
For events
If you use the "Change Selections" option on editing event registrations, you will get a fatal error of "Expected one EntityFinancialTrxn but found 0" if you try changing selections again.
This happens regardless of whether the first change has been paid for and regardless of whether the changes result in an increase or decrease in price.
Three scenarios to replicate:
Rainforest cup: paid at first, but not for the change
- make a new event registration on the backend, choose tiny tots ($800), and complete a payment of $800 by check)
- edit the registration, click change selections, and choose junior stars ($1000)
- edit the registration, click change selections (preferably in a new tab so you can see the error), and choose super stars ($1500)
- you'll get the fatal error "Expected one EntityFinancialTrxn but found 0"
Fall fundraiser: paid after first change
- make a new event registration on the backend, choose single ($50), pending pay later
- edit the registration, click change selections, and choose couple ($100)
- click record payment on the contribution, and pay $100
- edit the registration, click change selections (preferably in a new tab so you can see the error), and choose family ($200)
- you'll get the fatal error "Expected one EntityFinancialTrxn but found 0"
Summer solstice festival: paid every step of the way
- make a new event registration on the backend, choose soprano ($25), and complete a payment of $25 by check
- edit the registration, click change selections, and choose tenor ($40)
- click record payment on the contribution, and pay $15
- edit the registration, click change selections (preferably in a new tab so you can see the error), and choose bass ($50)
- you'll get the fatal error "Expected one EntityFinancialTrxn but found 0"
These examples all involve going upwards, but this also happens if you go downwards or from a low level to a high level and back to a low level. This also happens if you start as pay later and never pay anything.
The backtrace is as follows
CiviCRM_API3_Exception: "Expected one EntityFinancialTrxn but found 0" #0 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Price/BAO/LineItem.php(1076): civicrm_api3("EntityFinancialTrxn", "getsingle", (Array:4)) #1 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Price/BAO/LineItem.php(849): CRM_Price_BAO_LineItem->_getRelatedCancelFinancialTrxn("115") #2 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Price/BAO/LineItem.php(660): CRM_Price_BAO_LineItem->_getFinancialItemsToRecord("55", "civicrm_participant", "101", (Array:1)) #3 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Event/Form/ParticipantFeeSelection.php(242): CRM_Price_BAO_LineItem::changeFeeSelections((Array:9), "55", "participant", "101", (Array:1), (Array:2), 0) #4 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Core/Form.php(447): CRM_Event_Form_ParticipantFeeSelection->postProcess() #5 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php(169): CRM_Core_Form->mainProcess() #6 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php(136): CRM_Core_QuickForm_Action_Upload->realPerform(Object(CRM_Event_Form_ParticipantFeeSelection), "upload") #7 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Upload->perform(Object(CRM_Event_Form_ParticipantFeeSelection), "upload") #8 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Event_Form_ParticipantFeeSelection), "upload") #9 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Core/Controller.php(351): HTML_QuickForm_Page->handle("upload") #10 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Utils/Wrapper.php(113): CRM_Core_Controller->run() #11 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Core/Invoke.php(283): CRM_Utils_Wrapper->run("CRM_Event_Form_ParticipantFeeSelection", "Change Registration Selections", NULL) #12 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:14)) #13 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:4)) #14 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/drupal/civicrm.module(448): CRM_Core_Invoke::invoke((Array:4)) #15 [internal function](): civicrm_invoke("event", "participant", "feeselection") #16 /srv/buildkit/build/dmaster/includes/menu.inc(527): call_user_func_array("civicrm_invoke", (Array:3)) #17 /srv/buildkit/build/dmaster/index.php(21): menu_execute_active_handler() #18 {main}
For memberships
Looking at the code, it appears that the problem dates to changes made for CRM-20321. Consequently, I decided to try this with the new "Automatically update related contributions when Membership Type is changed" feature enabled.
- Create a new Student membership, and record a contribution paid by check.
- Edit the membership to be a General membership.
- Edit the membership to be a Lifetime membership (remove the end date so the form doesn't yell at you).
- Same fatal error: "Expected one EntityFinancialTrxn but found 0"
Here's the backtrace of that:
CiviCRM_API3_Exception: "Expected one EntityFinancialTrxn but found 0" #0 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Price/BAO/LineItem.php(1076): civicrm_api3("EntityFinancialTrxn", "getsingle", (Array:4)) #1 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Price/BAO/LineItem.php(849): CRM_Price_BAO_LineItem->_getRelatedCancelFinancialTrxn("119") #2 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Price/BAO/LineItem.php(660): CRM_Price_BAO_LineItem->_getFinancialItemsToRecord("12", "civicrm_membership", "33", (Array:1)) #3 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Member/Form/Membership.php(1743): CRM_Price_BAO_LineItem::changeFeeSelections((Array:13), "12", "membership", "33", (Array:1), (Array:2), 50) #4 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Member/Form/Membership.php(1686): CRM_Member_Form_Membership->updateContributionOnMembershipTypeChange((Array:12), Object(CRM_Member_BAO_Membership)) #5 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Member/Form/Membership.php(920): CRM_Member_Form_Membership->submit() #6 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Core/Form.php(447): CRM_Member_Form_Membership->postProcess() #7 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php(169): CRM_Core_Form->mainProcess() #8 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php(136): CRM_Core_QuickForm_Action_Upload->realPerform(Object(CRM_Member_Form_Membership), "upload") #9 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Upload->perform(Object(CRM_Member_Form_Membership), "upload") #10 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Member_Form_Membership), "upload") #11 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Core/Controller.php(351): HTML_QuickForm_Page->handle("upload") #12 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Member/Page/Tab.php(302): CRM_Core_Controller->run() #13 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Member/Page/Tab.php(375): CRM_Member_Page_Tab->edit() #14 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Core/Invoke.php(309): CRM_Member_Page_Tab->run((Array:4), NULL) #15 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:14)) #16 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:4)) #17 /srv/buildkit/build/dmaster/sites/all/modules/civicrm/drupal/civicrm.module(448): CRM_Core_Invoke::invoke((Array:4)) #18 [internal function](): civicrm_invoke("contact", "view", "membership") #19 /srv/buildkit/build/dmaster/includes/menu.inc(527): call_user_func_array("civicrm_invoke", (Array:3)) #20 /srv/buildkit/build/dmaster/index.php(21): menu_execute_active_handler() #21 {main}