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

dev/core#3059 Regression fix - be tolerant with smarty money #22727

Merged
merged 1 commit into from
Feb 9, 2022

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Feb 8, 2022

Overview

To replicate - create a custom field of type money - mine was against entity contribution.
Create a contribution (or whatever) with the field and give it a value greater than 1000.
Attempt to view - fatal error

Before

image

After

Loads

Technical Details

The issue is the php layer is formatting it to money -and the smarty does so again. By the second time a value > 999 is no longer valid (in US locale) and it fatals. I would expect this to be a problem in European locales for smaller values.

The fix makes seems comparible with the prior laxity. I have also already done an extended reports release which fixes the source issue in reports (ie formats only once...)

Comments

I've seen issues in extended reports and in core where already-formatted money from
custom fields is formatted again in the smarty layer and, with recent changes
, throwing an exception when the money is greater than 1000
(because the presence of a comma makes it invalid). This adds tolerance
that seems consistent with prior code
@civibot
Copy link

civibot bot commented Feb 8, 2022

(Standard links)

@civibot civibot bot added the 5.47 label Feb 8, 2022
@eileenmcnaughton eileenmcnaughton changed the title Regression fix - be tolerant with smarty money dev/core#3059 Regression fix - be tolerant with smarty money Feb 8, 2022
@eileenmcnaughton
Copy link
Contributor Author

Attempt to tackle root cause in view pages #22728

@demeritcowboy
Copy link
Contributor

demeritcowboy commented Feb 8, 2022

It only seems to come up on contributions, so I'm just trying to figure out if this is the right fix. For non-us, the error does come up for smaller values but again only on contributions. (Sidenote: For non-us it comes up even if you don't fill in a value, because it then tries to format 0,00.)

@eileenmcnaughton
Copy link
Contributor Author

@demeritcowboy hmm - that's interesting!

I do think formatting at the tpl layer (only) is the right fix probably

@eileenmcnaughton
Copy link
Contributor Author

@demeritcowboy I think your comment was intended for #22728 & not this PR?

@totten
Copy link
Member

totten commented Feb 8, 2022

Right, so you're saying that there's two patches - #22727 is a broader (more rougher) mitigation for 5.46-5.47, and #22728 is narrower (but more correct) fix for 5.48+.

That seems like a fair split to me...

@eileenmcnaughton
Copy link
Contributor Author

@totten yep - in addition - I don't think the instance that #22728 fixes will be the last of them - I found 2 in the extended reports extension - hence I added a Civi::log() call but not a noisier notice for now

@totten
Copy link
Member

totten commented Feb 9, 2022

So I did some r-run and confirmed that this mitigates the error - so you can now view the data.

I compared the behavior to 5.45 (default locale=fr_FR, default currency=EUR, thousands='.', decimal=','):

Screen Shot 2022-02-08 at 8 06 20 PM

Here's #22727 (this PR; fixes crash; missing currency symbol; fixes separators):

Screen Shot 2022-02-08 at 8 09 28 PM

And here's #22728 (fixes crash; has symbol; fixes separators):

Screen Shot 2022-02-08 at 8 25 27 PM

So I can confirm that the present (generic) patch does mitigate the biggest problem (the crash), and it makes sense that it would mitigate across more use-cases. But the narrower #22728 does give a better outcome (for this specific screen).

Would it be crazy to put both patches (#22727, #22728) on both branches (5.46,5.47)?

@totten
Copy link
Member

totten commented Feb 9, 2022

Definitely an improvement. Since the r-run is fine, I'll merge. Other fixes can be done as additional PRs.

@totten totten merged commit c27d601 into civicrm:5.47 Feb 9, 2022
@eileenmcnaughton eileenmcnaughton deleted the mod_money branch February 9, 2022 04:51
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.

3 participants