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/financial#171 - Trigger an error if non-numeric value passed to Money::format() #19938

Merged
merged 1 commit into from
Mar 31, 2021

Conversation

demeritcowboy
Copy link
Contributor

@demeritcowboy demeritcowboy commented Mar 29, 2021

Overview

https://lab.civicrm.org/dev/financial/-/issues/171#note_56673

To trigger this you can do something like put {'aaa'|crmMoney} in any template and then visit that page. You should see an error if you have on-screen errors turned on (drupal).

Before

Confusing warning about missing INTL when non-numeric values are passed to Money::format()

After

User deprecated function: Formatting non-numeric values is no longer supported: <the offending value>

Technical Details

It was being intercepted before because it made tests fail on php 7.4 prematurely. No longer a need to do this so this will also see if any more tests fail now.

Comments

@civibot
Copy link

civibot bot commented Mar 29, 2021

(Standard links)

@civibot civibot bot added the master label Mar 29, 2021
@demeritcowboy
Copy link
Contributor Author

api_v3_ReportTemplateTest.testDeferredRevenueReport
CRM_Core_Page_HookTest.testFormsCallBuildFormOnce
CRM_Core_Smarty_plugins_CrmMoneyTest.testMoney with data set #2
CRM_Core_FormTest.testOpeningForms with data set "Fulltext search"
CRM_Core_InvokeTest.testInvokeDashboardForNonAdmin
CRM_Core_PseudoConstantTest.testOptionValues
CRM_Core_PseudoConstantTest.testContactTypes
CRM_Core_PseudoConstantTest.testGetTaxRates
CRM_Custom_Form_OptionTest.testEditCustomFieldOptionValue
CRM_Export_BAO_ExportTest.testAdditionalReturnProperties with data set #2
CRM_Export_BAO_ExportTest.testDefaultReturnProperties with data set #2
CRM_Export_BAO_ExportTest.testGetSQLColumnsAndHeaders with data set #2
CRM_Member_BAO_QueryTest.testMembershipDateWhereSearchBuilder with data set #0
CRM_Member_BAO_QueryTest.testMembershipDateWhereSearchBuilder with data set #1
CRM_Member_BAO_QueryTest.testMembershipDateWhereSearchBuilder with data set #2
CRM_Member_BAO_QueryTest.testConvertEntityFieldSingleValue
CRM_Member_BAO_QueryTest.testConvertEntityFieldMultipleValueEntityRef
CRM_Member_BAO_QueryTest.testConvertEntityFieldMultipleValueLegacy
CRM_Member_BAO_QueryTest.testConvertEntityFieldMultipleValueEntityRefDoubleRun
CRM_Report_Utils_ReportTest.testOutputPrint
CRM_Upgrade_Incremental_php_FiveTwentyTest.testChangeCaseTypeAutoassignee
CRM_Upgrade_Incremental_php_FiveTwentyTest.testConvertRoleLabelsToNames

@eileenmcnaughton
Copy link
Contributor

@demeritcowboy more than I expected!

@demeritcowboy
Copy link
Contributor Author

I was looking at some. I think several might be bad smarty that somehow ends up calling crmMoney indirectly but the error gets swallowed up somewhere so it's never come up before.

@eileenmcnaughton
Copy link
Contributor

@demeritcowboy I took a look at that first one & it's pretty dodgey - what gets passed in is

'100, 100'

I think this is OK #19940

(I hope we don't have to go through every single one & several are failing on the same thing....)

@eileenmcnaughton
Copy link
Contributor

Also #19941

@eileenmcnaughton
Copy link
Contributor

test this please

@eileenmcnaughton
Copy link
Contributor

I just gave this a very optimistic MOP

@eileenmcnaughton
Copy link
Contributor

They didn't just melt away

Test Result (20 failures / +20)
CRM_Core_Smarty_plugins_CrmMoneyTest.testMoney with data set #2
CRM_Core_FormTest.testOpeningForms with data set "Fulltext search"
CRM_Core_InvokeTest.testInvokeDashboardForNonAdmin
CRM_Core_PseudoConstantTest.testOptionValues
CRM_Core_PseudoConstantTest.testContactTypes
CRM_Core_PseudoConstantTest.testGetTaxRates
CRM_Custom_Form_OptionTest.testEditCustomFieldOptionValue
CRM_Export_BAO_ExportTest.testAdditionalReturnProperties with data set #2
CRM_Export_BAO_ExportTest.testDefaultReturnProperties with data set #2
CRM_Export_BAO_ExportTest.testGetSQLColumnsAndHeaders with data set #2
CRM_Member_BAO_QueryTest.testMembershipDateWhereSearchBuilder with data set #0
CRM_Member_BAO_QueryTest.testMembershipDateWhereSearchBuilder with data set #1
CRM_Member_BAO_QueryTest.testMembershipDateWhereSearchBuilder with data set #2
CRM_Member_BAO_QueryTest.testConvertEntityFieldSingleValue
CRM_Member_BAO_QueryTest.testConvertEntityFieldMultipleValueEntityRef
CRM_Member_BAO_QueryTest.testConvertEntityFieldMultipleValueLegacy
CRM_Member_BAO_QueryTest.testConvertEntityFieldMultipleValueEntityRefDoubleRun
CRM_Report_Utils_ReportTest.testOutputPrint
CRM_Upgrade_Incremental_php_FiveTwentyTest.testChangeCaseTypeAutoassignee
CRM_Upgrade_Incremental_php_FiveTwentyTest.testConvertRoleLabelsToNames

@demeritcowboy
Copy link
Contributor Author

The ones that trigger civicase errors are technically correct I think, I just have no idea why this PR causes that. In secure mode, smarty should reject loading a tpl that isn't under templates or an authorized directory. The fact that the case sample tpl lives under CRM is a weird oddity, cuz civicase. I'm really curious though how this PR triggers those errors.

@demeritcowboy
Copy link
Contributor Author

Oh I think I know. Smarty is a static singleton. Calling fetch('string:...') sets secure mode. When it fails, secure mode never gets reset, so the other tests start running under secure mode.

@eileenmcnaughton
Copy link
Contributor

ohhhh - go super-sleuth

@monishdeb
Copy link
Member

Test failure seems related https://test.civicrm.org/job/CiviCRM-Core-PR/40101/

@demeritcowboy
Copy link
Contributor Author

#19958

@demeritcowboy
Copy link
Contributor Author

jenkins retest this please

@seamuslee001 seamuslee001 merged commit 9e81577 into civicrm:master Mar 31, 2021
@seamuslee001
Copy link
Contributor

Well done all here

@eileenmcnaughton
Copy link
Contributor

Oh wow - it passed!

@demeritcowboy
Copy link
Contributor Author

Yay!

@demeritcowboy demeritcowboy deleted the php74-money branch March 31, 2021 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants