Provide precautionary handling for theoretical error scenario.
authoreileen <emcnaughton@wikimedia.org>
Wed, 6 Nov 2019 19:40:37 +0000 (08:40 +1300)
committereileen <emcnaughton@wikimedia.org>
Wed, 6 Nov 2019 23:27:52 +0000 (12:27 +1300)
commitcc9f28826bbde464e853d138d2b74914e539a10f
tree78a749731258527b69201b2581269174700fe3f6
parentc11118b2376db4ac97f8c11fa9b4a813cdc0a53e
Provide precautionary handling for theoretical error scenario.

While testing payments I hit a bug where I tried to add a payment to a contribution with no financial items.

I never managed to replicate it again or determine how the payment came to be in that state but
it's been playing in my mind that people could get fatal errors if the financial_items don't exist
and dealing with those as regression reports will very tough. So my plan is
- for 5.20 add this extra routine to create it if it does not exist
- use this mechanism + more digging to figure out how legit an issue it is https://github.com/civicrm/civicrm-core/pull/15706
- in future releases 'get noisy' about having to create them if they don't exist
- eventually remove this routine
CRM/Financial/BAO/Payment.php
tests/phpunit/api/v3/ContributionTest.php
tests/phpunit/api/v3/PaymentTest.php