-
-
Notifications
You must be signed in to change notification settings - Fork 827
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
Remove CRM_Utils_Array::value from BAO_Contribution #18207
Conversation
(Standard links)
|
First fail relates. Note we have hit regressions with this sort of change so I wouldn't personally be comfortable reviewing changes to so many different functions in one hit /home/jenkins/bknix-dfl/build/core-18207-6xqpc/web/sites/all/modules/civicrm/CRM/Contribute/BAO/Contribution.php:102 |
2265776
to
4813a59
Compare
ab26cf0
to
cd6076a
Compare
cd6076a
to
e5ed0fa
Compare
|
||
$currency = $params['prevContribution']->currency; | ||
if ($params['contribution']->currency) { | ||
$currency = $params['contribution']->currency; | ||
} | ||
$previousLineItemTotal = CRM_Utils_Array::value('line_total', CRM_Utils_Array::value($fieldValueId, $previousLineItems), 0); | ||
$previousLineItemTotal = $previousLineItems[$fieldValueId]['line_total'] ?? 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically when there's a default value passed in it's not a 1-1 swap with ??
. Consider cv ev "$a['b'] = NULL; var_dump(CRM_Utils_Array::value('b', $a, 4)); var_dump($a['b'] ?? 4);"
. The first outputs null and the second outputs 4. So to review you need to think about whether null would be possible/make sense in the original. For these 0
ones I think they're ok.
@@ -2312,7 +2312,7 @@ public static function transitionComponents($params, $processContributionObject | |||
$membership->membership_type_id, | |||
(array) $membership | |||
); | |||
$membership->status_id = CRM_Utils_Array::value('id', $status, $membership->status_id); | |||
$membership->status_id = $status['id'] ?? $membership->status_id; | |||
$membership->save(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this one's ok because of the way getMembershipStatusByDate works. id
would either be missing completely or would be a number, so the swap is valid.
@@ -4022,7 +4011,7 @@ public static function buildOptions($fieldName, $context = NULL, $props = []) { | |||
'version' => 3, | |||
'id' => ($props['contribution_page_id']), | |||
]); | |||
$types = (array) CRM_Utils_Array::value('payment_processor', $page, 0); | |||
$types = (array) $page['payment_processor'] ?? 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need brackets since the cast will apply to the first one first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@demeritcowboy if you want to pull out a handful of these to a reviewer's commit I'm happy to merge them - maybe a half dozen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I pulled out a few - #18391.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - I'll close this for now & if anyone wants to use it to help with another round they can (although from past experience doing these is easy - getting them reviewed is hard)
Overview
Remove deprecated
CRM_Utils_Array::value
from CRM_Contribute_BAO_ContributionBefore
CRM_Utils_Array::value
After
??
Technical Details
Comments