Respect calling code passing in 'null
authoreileen <emcnaughton@wikimedia.org>
Fri, 6 Sep 2019 21:47:43 +0000 (09:47 +1200)
committereileen <emcnaughton@wikimedia.org>
Wed, 9 Oct 2019 14:37:38 +0000 (16:37 +0200)
commit88123faced0e9f76096ee0d0204bb7e676da85be
treea68332b70f15b9148fea98430dab5e95817cc75f
parente74fb1c1f167bd4635075aae4569c1666dc0d4b4
Respect calling code passing in 'null
 for creditnote_id.

The credit note code was implemented in core quite a while ago, before we were really pushing these things
out to extensions. It was implemented such that it iterates through all credit notes & has performance
implications in order to meet a use case that is not common to all.

Ideally we would move it to an extension, but short of that we can at least respect
calling code setting the value to 'null' in order to override it.

There is no precedent anywhere in our code for the BAO to deliberately override efforts by
calling code to null out a value & in this case it solves a performance problem too

Probably we should longer term simply have a hook

hook::getCreditNoteID() & more this function to an extension called by that hook
CRM/Contribute/BAO/Contribution.php