[REF] Remove duplicate checks for an array key existing
authorColeman Watts <coleman@civicrm.org>
Mon, 13 Apr 2020 21:00:59 +0000 (17:00 -0400)
committerColeman Watts <coleman@civicrm.org>
Mon, 13 Apr 2020 21:12:27 +0000 (17:12 -0400)
15 files changed:
CRM/Contact/Form/Edit/CustomData.php
CRM/Contact/Page/Inline/CommunicationPreferences.php
CRM/Contact/Page/Inline/Demographics.php
CRM/Contact/Page/View/Summary.php
CRM/Contact/Page/View/Vcard.php
CRM/Contribute/BAO/ContributionSoft.php
CRM/Contribute/Form/Contribution/Confirm.php
CRM/Contribute/Form/ContributionView.php
CRM/Core/BAO/Address.php
CRM/Core/BAO/UFJoin.php
CRM/Event/Form/Registration/Confirm.php
CRM/Report/BAO/ReportInstance.php
CRM/Report/Form/Grant/Statistics.php
api/v3/Contact.php
extern/url.php

index 0d65448ca2c8d2b771b2684d81dd59e928d47d42..4f1b517802cd24ea7f4013930ce5158d9f2c7672 100644 (file)
@@ -52,16 +52,13 @@ class CRM_Contact_Form_Edit_CustomData {
    *   Reference to the form object.
    */
   public static function buildQuickForm(&$form) {
-    if (!empty($form->_submitValues)) {
-      if ($customValueCount = CRM_Utils_Array::value('hidden_custom_group_count', $form->_submitValues)) {
-        if (is_array($customValueCount)) {
-          if (array_key_exists(0, $customValueCount)) {
-            unset($customValueCount[0]);
-          }
-          $form->_customValueCount = $customValueCount;
-          $form->assign('customValueCount', $customValueCount);
-        }
+    $customValueCount = $form->_submitValues['hidden_custom_group_count'] ?? NULL;
+    if (is_array($customValueCount)) {
+      if (array_key_exists(0, $customValueCount)) {
+        unset($customValueCount[0]);
       }
+      $form->_customValueCount = $customValueCount;
+      $form->assign('customValueCount', $customValueCount);
     }
     CRM_Custom_Form_CustomData::buildQuickForm($form);
 
index 9b95964b0191e8dc02cd7b413d8e33453d067b1d..4c4ca42054033d71a095c7c253936a83dd0ae341 100644 (file)
@@ -40,7 +40,7 @@ class CRM_Contact_Page_Inline_CommunicationPreferences extends CRM_Core_Page {
     $communicationStyle = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id');
     if (!empty($communicationStyle)) {
       if (!empty($defaults['communication_style_id'])) {
-        $defaults['communication_style_display'] = $communicationStyle[CRM_Utils_Array::value('communication_style_id', $defaults)];
+        $defaults['communication_style_display'] = $communicationStyle[$defaults['communication_style_id']];
       }
       else {
         // Make sure the field is displayed as long as it is active, even if it is unset for this contact.
index 33162222b76f0a258c5999d9d1653004483b3c52..b211df4dcf0eb74c81db0895a2ef736eae3c5b91 100644 (file)
@@ -36,7 +36,7 @@ class CRM_Contact_Page_Inline_Demographics extends CRM_Core_Page {
 
     if (!empty($defaults['gender_id'])) {
       $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id');
-      $defaults['gender_display'] = $gender[CRM_Utils_Array::value('gender_id', $defaults)];
+      $defaults['gender_display'] = $gender[$defaults['gender_id']];
     }
     $this->assignFieldMetadataToTemplate('Contact');
 
index 6163ab941628001f40cb095f5e50a3874c1072d8..f411a21c42da3b752699b21d679384e5fecddf80 100644 (file)
@@ -183,7 +183,7 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View {
     $communicationStyle = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id');
     if (!empty($communicationStyle)) {
       if (!empty($defaults['communication_style_id'])) {
-        $defaults['communication_style_display'] = $communicationStyle[CRM_Utils_Array::value('communication_style_id', $defaults)];
+        $defaults['communication_style_display'] = $communicationStyle[$defaults['communication_style_id']];
       }
       else {
         // Make sure the field is displayed as long as it is active, even if it is unset for this contact.
index a730ddb18f39c5c7e7508f5c514bae522920fb17..eb514ca0498645f018c8d8ca8e96c8995dbf5e58 100644 (file)
@@ -73,7 +73,7 @@ class CRM_Contact_Page_View_Vcard extends CRM_Contact_Page_View {
     }
 
     if (!empty($defaults['birth_date'])) {
-      $vcard->setBirthday(CRM_Utils_Array::value('birth_date', $defaults));
+      $vcard->setBirthday($defaults['birth_date']);
     }
 
     if (!empty($defaults['home_URL'])) {
@@ -98,11 +98,11 @@ class CRM_Contact_Page_View_Vcard extends CRM_Contact_Page_View {
         $locality = $location['city'] ?? NULL;
         $region = NULL;
         if (!empty($location['state_province_id'])) {
-          $region = $stateProvices[CRM_Utils_Array::value('state_province_id', $location)];
+          $region = $stateProvices[$location['state_province_id']];
         }
         $country = NULL;
         if (!empty($location['country_id'])) {
-          $country = $countries[CRM_Utils_Array::value('country_id', $location)];
+          $country = $countries[$location['country_id']];
         }
 
         $postcode = $location['postal_code'] ?? NULL;
index 679fe80565a8fdf65af9b3b20cbe657851e3efde..40fe273e22c516793d5705a67d8bb2f7d4d62188 100644 (file)
@@ -562,7 +562,7 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio
     switch ($profileContactType) {
       case 'Individual':
         if (array_key_exists('prefix_id', $params)) {
-          $honorName = CRM_Utils_Array::value(CRM_Utils_Array::value('prefix_id', $params),
+          $honorName = CRM_Utils_Array::value($params['prefix_id'],
             CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id')
           );
           unset($profileFields['prefix_id']);
@@ -571,7 +571,7 @@ class CRM_Contribute_BAO_ContributionSoft extends CRM_Contribute_DAO_Contributio
         unset($profileFields['first_name']);
         unset($profileFields['last_name']);
         if (array_key_exists('suffix_id', $params)) {
-          $honorName .= ' ' . CRM_Utils_Array::value(CRM_Utils_Array::value('suffix_id', $params),
+          $honorName .= ' ' . CRM_Utils_Array::value($params['suffix_id'],
               CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id')
             );
           unset($profileFields['suffix_id']);
index 647cdb71378480edc0e53ac492d459088b868ebb..88adb5db943e2577794f608cc1987972c2ab4041 100644 (file)
@@ -101,7 +101,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       }
       $pledgeParams['create_date'] = $pledgeParams['start_date'] = $pledgeParams['scheduled_date'] = date("Ymd");
       if (!empty($params['start_date'])) {
-        $pledgeParams['frequency_day'] = intval(date("d", strtotime(CRM_Utils_Array::value('start_date', $params))));
+        $pledgeParams['frequency_day'] = intval(date("d", strtotime($params['start_date'])));
         $pledgeParams['start_date'] = $pledgeParams['scheduled_date'] = date('Ymd', strtotime(CRM_Utils_Array::value('start_date', $params)));
       }
       $pledgeParams['status_id'] = $contribution->contribution_status_id;
@@ -947,10 +947,10 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
           foreach ($lineItemValue as $key => $value) {
             if (isset($value['tax_amount']) && isset($value['tax_rate'])) {
               if (isset($dataArray[$value['tax_rate']])) {
-                $dataArray[$value['tax_rate']] = $dataArray[$value['tax_rate']] + CRM_Utils_Array::value('tax_amount', $value);
+                $dataArray[$value['tax_rate']] = $dataArray[$value['tax_rate']] + $value['tax_amount'];
               }
               else {
-                $dataArray[$value['tax_rate']] = $value['tax_amount'] ?? NULL;
+                $dataArray[$value['tax_rate']] = $value['tax_amount'];
               }
             }
           }
index fc0181933a1228c8c836b6ea5a05d164c227fc6b..f0cbfbe943519891a1a669a4cb564d0e083805e8 100644 (file)
@@ -108,7 +108,7 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form {
 
     // show billing address location details, if exists
     if (!empty($values['address_id'])) {
-      $addressParams = ['id' => CRM_Utils_Array::value('address_id', $values)];
+      $addressParams = ['id' => $values['address_id']];
       $addressDetails = CRM_Core_BAO_Address::getValues($addressParams, FALSE, 'id');
       $addressDetails = array_values($addressDetails);
       $values['billing_address'] = $addressDetails[0]['display'];
index c86d73f8c1248dd73d202c073b4ed3a0d5ef7da4..e22a25cecd2c1e61a94eb029b36528920b8f7956 100644 (file)
@@ -66,8 +66,8 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address {
 
       $addressExists = self::dataExists($value);
       if (empty($value['id'])) {
-        if (!empty($addresses) && array_key_exists(CRM_Utils_Array::value('location_type_id', $value), $addresses)) {
-          $value['id'] = $addresses[CRM_Utils_Array::value('location_type_id', $value)];
+        if (!empty($addresses) && !empty($value['location_type_id']) && array_key_exists($value['location_type_id'], $addresses)) {
+          $value['id'] = $addresses[$value['location_type_id']];
         }
       }
 
index f9850e515a02d06daa6555745be4acb2043a3466..ebc21f037dcaffa2d0f51250eec251955b251b20 100644 (file)
@@ -90,7 +90,7 @@ class CRM_Core_BAO_UFJoin extends CRM_Core_DAO_UFJoin {
 
     // CRM-4377 (ab)uses the module column
     if (isset($params['module'])) {
-      $dao->module = $params['module'] ?? NULL;
+      $dao->module = $params['module'];
     }
     $dao->entity_table = $params['entity_table'] ?? NULL;
     $dao->entity_id = $params['entity_id'] ?? NULL;
@@ -143,7 +143,7 @@ class CRM_Core_BAO_UFJoin extends CRM_Core_DAO_UFJoin {
 
     // CRM-4377 (ab)uses the module column
     if (isset($params['module'])) {
-      $dao->module = $params['module'] ?? NULL;
+      $dao->module = $params['module'];
     }
     $dao->entity_table = $params['entity_table'] ?? NULL;
     $dao->entity_id = $params['entity_id'] ?? NULL;
index 4d2888b253e95c73772c129c045d51de17abd33f..4547e4c173de2faaa05f8ce4a0a5695cd680ea58 100644 (file)
@@ -1049,7 +1049,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration {
 
     // Add the billing names to the billing address, if a billing name is set
     if (!empty($params['billing_first_name'])) {
-      $params["address_name-{$form->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $params) . ' ' . CRM_Utils_Array::value('billing_last_name', $params);
+      $params["address_name-{$form->_bltID}"] = $params['billing_first_name'] . ' ' . CRM_Utils_Array::value('billing_middle_name', $params) . ' ' . CRM_Utils_Array::value('billing_last_name', $params);
       $fields["address_name-{$form->_bltID}"] = 1;
     }
 
index daeff31df15443d3e3d3841d4d72029fb9f5ba0b..a0950787c1badafceedcd0cf678376df7d07fd21 100644 (file)
@@ -114,10 +114,10 @@ class CRM_Report_BAO_ReportInstance extends CRM_Report_DAO_ReportInstance {
    */
   public static function &create(&$params) {
     if (isset($params['report_header'])) {
-      $params['header'] = $params['report_header'] ?? NULL;
+      $params['header'] = $params['report_header'];
     }
     if (isset($params['report_footer'])) {
-      $params['footer'] = $params['report_footer'] ?? NULL;
+      $params['footer'] = $params['report_footer'];
     }
 
     // build navigation parameters
index 6e8f893710805c881b84bca5e983d792516f3ec7..df5597aa615ad4620a21befbf64f2d6f8d68e3ab 100644 (file)
@@ -388,8 +388,7 @@ SELECT COUNT({$this->_aliases['civicrm_grant']}.id) as count ,
       }
 
       if (array_key_exists('civicrm_worldregion_name', $values)) {
-        $region = $values['civicrm_worldregion_name'] ?? NULL;
-        $region = ($region) ? $region : 'Unassigned';
+        $region = $values['civicrm_worldregion_name'] ?: 'Unassigned';
         $grantStatistics['civicrm_worldregion_name']['title'] = ts('By Region');
         self::getStatistics($grantStatistics['civicrm_worldregion_name'], $region, $values,
           $awardedGrants, $awardedGrantsAmount
@@ -397,8 +396,7 @@ SELECT COUNT({$this->_aliases['civicrm_grant']}.id) as count ,
       }
 
       if (array_key_exists('civicrm_address_country_id', $values)) {
-        $country = $countries[$values['civicrm_address_country_id']] ?? NULL;
-        $country = ($country) ? $country : 'Unassigned';
+        $country = $countries[$values['civicrm_address_country_id']] ?? 'Unassigned';
         $grantStatistics['civicrm_address_country_id']['title'] = ts('By Country');
         self::getStatistics($grantStatistics['civicrm_address_country_id'], $country, $values,
           $awardedGrants, $awardedGrantsAmount
@@ -414,8 +412,7 @@ SELECT COUNT({$this->_aliases['civicrm_grant']}.id) as count ,
       }
 
       if (array_key_exists('civicrm_contact_gender_id', $values)) {
-        $genderLabel = $gender[$values['civicrm_contact_gender_id']] ?? NULL;
-        $genderLabel = ($genderLabel) ? $genderLabel : 'Unassigned';
+        $genderLabel = $gender[$values['civicrm_contact_gender_id']] ?? 'Unassigned';
         $grantStatistics['civicrm_contact_gender_id']['title'] = ts('By Gender');
         self::getStatistics($grantStatistics['civicrm_contact_gender_id'], $genderLabel, $values,
           $awardedGrants, $awardedGrantsAmount
index ba581e57947526c3d6199e49436b29608c247613..2f02e9484c920560ebe8de3cb7c29903fa09bcc4 100644 (file)
@@ -930,7 +930,7 @@ function civicrm_api3_contact_getquick($params) {
   // Contact's based of relationhip type
   $relType = NULL;
   if (!empty($params['rel'])) {
-    $relation = explode('_', CRM_Utils_Array::value('rel', $params));
+    $relation = explode('_', $params['rel']);
     $relType = CRM_Utils_Type::escape($relation[0], 'Integer');
     $rel = CRM_Utils_Type::escape($relation[2], 'String');
   }
index 2627f4f013f5c42c9fd1bb6c8233cf7ebeb9549d..4b5ed69974eca8b3e4d2db1c72a90798874f0f1c 100644 (file)
@@ -8,12 +8,8 @@ CRM_Core_Config::singleton();
 
 // To keep backward compatibility for URLs generated
 // by CiviCRM < 1.7, we check for the q variable as well.
-if (isset($_GET['qid'])) {
-  $queue_id = $_GET['qid'] ?? NULL;
-}
-else {
-  $queue_id = $_GET['q'] ?? NULL;
-}
+$queue_id = $_GET['qid'] ?? $_GET['q'] ?? NULL;
+
 $url_id = $_GET['u'] ?? NULL;
 
 if (!$url_id) {