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

[REF] Switch CRM_Utils_Array::value to empty in conditionals #17091

Merged
merged 1 commit into from
May 4, 2020

Conversation

colemanw
Copy link
Member

Overview

Code refactor to fix some more cases of CRM_Utils_Array::value

@civibot
Copy link

civibot bot commented Apr 16, 2020

(Standard links)

@colemanw
Copy link
Member Author

It would be good to get this merged so it doesn't conflict with other PRs.

@@ -369,7 +369,7 @@ public function setDefaultValues() {
$defaults['total_amount'] = CRM_Utils_Money::format($total_value, NULL, '%a');
if (!empty($defaults['tax_amount'])) {
$componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id);
if (!(CRM_Utils_Array::value('membership', $componentDetails) || CRM_Utils_Array::value('participant', $componentDetails))) {
if (!(!empty($componentDetails['membership']) || !empty($componentDetails['participant']))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be clearer as empty($componentDetails['membership']) && empty($componentDetails['participant'])

@@ -1462,7 +1462,7 @@ protected function submit($submittedValues, $action, $pledgePaymentID) {
if ($this->_priceSetId && CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) {
//CRM-16833: Ensure tax is applied only once for membership conribution, when status changed.(e.g Pending to Completed).
$componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id);
if (!(CRM_Utils_Array::value('membership', $componentDetails) || CRM_Utils_Array::value('participant', $componentDetails))) {
if (!(!empty($componentDetails['membership']) || !empty($componentDetails['participant']))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here.

@@ -55,7 +55,7 @@ public static function _invoke($args) {
return NULL;
}
// CRM-15901: Turn off PHP errors display for all ajax calls
if (CRM_Utils_Array::value(1, $args) == 'ajax' || CRM_Utils_Array::value('snippet', $_REQUEST)) {
if (CRM_Utils_Array::value(1, $args) == 'ajax' || !empty($_REQUEST['snippet'])) {
ini_set('display_errors', 0);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The replacement is fine but this has bugged me for a while and I wonder if there's a way to only do this when in production. Devs should have errors mess up their snippets. 😈

@demeritcowboy
Copy link
Contributor

All the others look good.

@demeritcowboy
Copy link
Contributor

jenkins test this please

@colemanw
Copy link
Member Author

colemanw commented May 3, 2020

Thanks @demeritcowboy I've made the changes you suggested.

@seamuslee001 seamuslee001 merged commit 4038698 into civicrm:master May 4, 2020
@seamuslee001 seamuslee001 deleted the noArrayValue branch May 4, 2020 09:21
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.

3 participants