Skip to content
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

Handle possibility of fee_amount = '' #19120

Merged
merged 1 commit into from
Dec 9, 2020

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Dec 4, 2020

Overview

This patch responds a report from edgimar on Mattermost (WordPress):

Warning: A non-numeric value encountered in /home/mywebsite.com/wp-content/plugins/civicrm/civicrm/CRM/Contribute. /BAO/Contribution.php on line 356"

Warning: Cannot modify header information - headers already sent by 
(output started at /home/mywebsite.com/wp-content/plugins/civicrm/civicrm/CRM/Contribute/BAO/Contribution.php:356)
in /home/mywebsite.com/wp-content/plugins/civicrm/civicrm/CRM/Utils/System/Base.php on line 948"

These messages just show up on an empty white webpage after pressing submit.

The error appears to involve processing a contribution with fee_amount='' (empty-string). We cannot reproduce this circumstance organically. The fix is based on the assumption that it's happening somehow.

Before

An empty string is invalid for fee amount, leading to a fatal error.

After

The empty string is cast to 0.

@civibot civibot bot added the 5.33 label Dec 4, 2020
@civibot
Copy link

civibot bot commented Dec 4, 2020

(Standard links)

@kcristiano
Copy link
Member

@eileenmcnaughton I tried an r-run on 5.33 without the patch and could not reproduce.

After applying the patch, I was still able to successfully record a backend credit card contribution with fee amount blank.

This PR explicitly allows blank amounts, so it should be OK.

@mattwire
Copy link
Contributor

mattwire commented Dec 5, 2020

This isn't actually breaking anything though? And it's not clear if it's actually a regression? On live sites PHP warnings should be off (or at least configured to log and not to display).

As this is happening on submitting a new contribution I'm guessing it's related to a specific payment processor and a specific set of configuration params for the contribution page.

I have no problems with the patch per-se if it helps correct data issues but in my experience this kind of warning is usually pretty useful in pointing to an underlying issue with the configuration/payment processor and is probably hiding other problems.

@eileenmcnaughton
Copy link
Contributor Author

Yeah my feeling is that because we don't normally distinguish between fee_amount = '' and fee_amount = NULL in various places in code this is the sort of thing we could expect to cause bugs. We know that both are the equivalent of 0 here so casting to 0 seems like a sensible step

@seamuslee001
Copy link
Contributor

So during the Product Maintenance meeting we agreed that this should be merged but also @mattwire we thought that if you felt that if passing a blank string should trigger a deprecation warning or something like that (i.e a Civi Warning not a PHP Warning so won't hopefully trigger the headers issue) we would be ok with merging that in as well.

@seamuslee001 seamuslee001 merged commit edc5f11 into civicrm:5.33 Dec 9, 2020
@seamuslee001 seamuslee001 deleted the fee branch December 9, 2020 23:10
@mattwire
Copy link
Contributor

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants