-
-
Notifications
You must be signed in to change notification settings - Fork 821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP ensure line items without price field id set doesn't cause problems #23087
WIP ensure line items without price field id set doesn't cause problems #23087
Conversation
(Standard links)
|
I'd love to get your feedback on this one @eileenmcnaughton - thanks!! |
Also wondering if, @JoeMurray, you have any thoughts since I know you have spent a lot of time on the financial side of CiviCRM. Are all line items exepcted to have a price field id set? |
@jmcclelland yes - I think the current model IS that all line items are attached to a price set - having said that we have had some soft discussions about changing it so you can mix and match lines from different price sets as part of how we might add creating orders to form builder - but the underlying work for that isn;t done at this stage |
@jmcclelland for 'simple' contributions the default price set is expected. - the api to create orders should or the repeattransaction api should ensure that is the case & as long as the custom code is using those core api then it is a core bug if price_set_id is not populated for some reason |
Thanks for the feedback Eileen. So far this doesn't seem to be a widespread problem with Powerbase sites. Only two of our sites seem to have a signficant number of line items without a Surveying all of our sites I found:
So, all in all, I've narrowed it down to one site with over 3,000 broken line items, one site with about 100, one site with 1 and another site with 2. I'm guessing the sites with 1 and 2 are just weird flukes and will try to find similarities between the other two sites to see if I can find a pattern. For now I'll close this PR. Thank you! |
Have fun @jmcclelland |
For the record, I tracked the problem down to groups receiving recurring contributions via a webform who did not have the transaction legacy extension installed, which feels like a very solid explanation for the problem. Thanks for your help @eileenmcnaughton! |
@jmcclelland I think the latest webform doesn't require that? |
For the record, it appears that the But actually...the fix for Drupal 8 does not seem to really be a fix - it seems to just copy the old legacy code from CiviCRM core. So you get all the same badness but without the deprecation warnings. |
@jmcclelland oh ok.... |
We've encountered this issue on at least 2 sites, after upgrading to ESR 5.45 |
@jackrabbithanna yes - line items DO need a price_field_id - that is part of the data schema & core + supported core apis do ensure that there is one - that old transact api never seemed to go away despite us telling people it wasn't tested or supported - but I don't know exactly why it would have created contributions which didn't have valid line items since AFAIK it called Contribution.create api which Does |
Ok, good to know. I know that it is possible to create line items via APIv3 without a price field id, that is no API error or SQL constraint error. |
Yeah - we should really have that constraint since the code expects it |
Addresses https://lab.civicrm.org/dev/core/-/issues/3150
Overview
A recent change (https://lab.civicrm.org/dev/core/-/commit/4df23f2a270c08bc42fd1ff93fcfe318ecdc0e19) causes CiviCRM to expect all line items to have a value for the
price_field_id
. In some workflows, a line item with a NULLprice_field_id
causes a back trace when browsing contributions and when processing new payment processor charges.Before
Steps to reproduce (Note: I don't know how to "naturally" create a contribution with a line item that has a NULL
price_field_id
or even if it's possible):price_field_id
to NULL.[You have to open the console and open the ajax call in a new tab to see the traceback message.]
After
After changing the code to detect a NULL
price_field_id
and setting the default price set ID automatically, the problem is resolved.Technical Details
It's not clear to me whether all line item really should have a price field id set (and it should be set to the default value for contributions or memberships depending on the line item itself) OR if CiviCRM should accomodate line items wihtout price field ids set.
This PR provides a test to demonstrate the problem and experiments with the accomodation approach to see what it would look like to gracefully handle that situation in at least one known worflow where a missing line item is found.
Would it be better to have an upgrade script simply fill in the missing values in the
civicrm_line_item
table???Comments
This problem has serious implications for payment processors. For example, with iATS, it can lead to monthly recurring donors getting charged daily.