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

Use propertyBag in doPayment #20022

Merged
merged 1 commit into from
Apr 11, 2021

Conversation

mattwire
Copy link
Contributor

@mattwire mattwire commented Apr 9, 2021

Overview

This fixes the test failure in #17886. If a propertyBag is passed into doPayment you get a PHP notice:
Deprecated function PropertyBag array access for core property 'amount', use getAmount().

Currently the eventcart PR is the only place that passes a propertyBag into doPayment so it triggers this notice.

Before

PHP notice because a property is not accessed via it's standard method.

After

Property is not accessed via it's standard method.

Technical Details

Comments

@civibot
Copy link

civibot bot commented Apr 9, 2021

(Standard links)

@civibot civibot bot added the master label Apr 9, 2021
@eileenmcnaughton
Copy link
Contributor

Yep - this makes sense & I think test cover is adequate on this

@eileenmcnaughton eileenmcnaughton merged commit 8896722 into civicrm:master Apr 11, 2021
@eileenmcnaughton
Copy link
Contributor

eileenmcnaughton commented Apr 11, 2021

@mattwire I merged this but I'm having misgivings now - we need to make sure $params['amount'] works since it's not just the CRM_Core_Payment class that will be accessing $params['amount'] - but likely a whole swag of processors 'out there'. Given that most known flows have passed $params['amount'] to date it's implictlly part of the contract. We need to ensure that it continues to work without e-notices (& if that is broken in event cart we actually need to fix it to pass out $params['amount']) - or something that can be accessed in that way without notices

@mattwire mattwire deleted the dopaymentpropertybag branch April 11, 2021 19:59
@mattwire
Copy link
Contributor Author

This PR won't break anything because we are not passing the propertyBag on anywhere - but the eventcart implementation demonstrates the issues that payment processors that haven't updated to use propertyBag will face.
All payment processors written/maintained by MJW natively support propertyBag and do the recommended propertybag::cast($params) at the start of doPayment - that's the only way to guarantee what your input is. If you look at https://lab.civicrm.org/dev/financial/-/issues/133#note_38422 you'll see we discussed the need for a way to allow processors to transition.

@eileenmcnaughton
Copy link
Contributor

@mattwire yeah - I agree this won't break anything - it just removes a guard rail because we can't change event cart to pass out propertyBag unless it will work with all processors & this removes one of the places where we might have detected that it didn't work.

I see you are still thinking that supportsPropertyBag might be part of the transition - I don't think that applies to parameters - only to the possibility that they might be using array functions that would break

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.

2 participants