-
-
Notifications
You must be signed in to change notification settings - Fork 824
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#3977 Handle dodgier calls to setBillingCountry in property bag. #24927
dev/core#3977 Handle dodgier calls to setBillingCountry in property bag. #24927
Conversation
(Standard links)
|
@artfulrobot Have not tested yet but looks good - I like the approach and especially the warning "Given input is plain weird." |
This looks good to me (I haven't reviewed in detail) & is closer to what I thought the point of the I would note that primary way in which values are passed to a) document any change in contract - ie if we are deprecating some keys & 'requesting' others that needs to be clear at https://docs.civicrm.org/dev/en/latest/extensions/payment-processors/create/#billing-fields I would push for the more visible / test killing deprecation warnings over the logging because it shows up in our dev environments & unit tests |
Glad you're happy, and thanks for the review :-)
yeah, we just disagree here, but that's ok. To me, property bag was not there to make up for sloppy coding elsewhere, it was to highlight it. Otherwise we'll continue to be sloppy and nobody will know whether it's
Yes, that doc needs a lot of work. It's a great example of how messed up the CRM_Core_Payment class is in terms of separation of concerns etc. - e.g. it documents getters and setters/params but that class should not even be storing that data. IMHO. But I agree that we should document that billing country needs to be ISO-2.
test-killing deprecations - yes I always forget those. I can't recall how to (a) do it - I can grep around though, and (b) how this affects a test when you want to test that a deprecation message has been generated? |
@artfulrobot this is how we add a deprecation error Generally I would say our normal approach to highlight sloppy code is to add deprecation warnings & also to leverage our unit tests to find inconsistencies & lock in consistent behaviour (e.g registering a hook in our unit test classes that errors if the correct params are not set or are invalid). The However, it's probably good that we have flushed out that this is the underlying difference in our thinking about |
@eileenmcnaughton ok how's this looking?
On the other behaviour of PropertyBag, pretty much all setters have been written to throw exceptions if invalid input is received. We did have it emit more deprecation/logs stuff in the past but this resulted in complaints about log size(!). Also I think we - I - thought that it would reveal dodgy calls much sooner than it has, which would clean up the upstream code (typically the changes are minor). But I guess the people that do the clean up are people who run tests, and if there's no tests covering that, the problem isn't shown up in testing and is instead found in production where people don't notice the warnings, so don't fix code. As a result we have had a long protracted series of adding heuristics and guesswork and munges, so I guess it's failed as an initiative or it just has a long way to go yet. Anyway, hopefully this PR whacks this mole for now! |
@artfulrobot - the alternative to your last patch is
In general the However, I have some ideas about how we could improve code-quality enforcement via tests. and / or adding a new v4 Payment.pay api & migrating to it |
@eileenmcnaughton I think we still need my last patch to use
Sounds good feel free to @ me on discussions and I'll try to join in. Honestly I'm thinking we need something to replace |
@artfulrobot OK - if you prefer it the way it is then let's merge it! |
Alternative to #24903
As a solution to https://lab.civicrm.org/dev/core/-/issues/3977 & to getting back the regression in https://lab.civicrm.org/dev/core/-/issues/3918
This does what @mattwire's suggestion does but includes @eileenmcnaughton's suggestion of munging.
TL;DR:
''
(empty string). boo.