-
-
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
[REF] Remove duplicate checks for an array key existing #17069
Conversation
(Standard links)
|
96f04a3
to
2cfe2cf
Compare
retest this please |
$customValueCount = $form->_submitValues['hidden_custom_group_count'] ?? NULL; | ||
if (is_array($customValueCount)) { | ||
if (array_key_exists(0, $customValueCount)) { | ||
unset($customValueCount[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.
I don't know what the keys of customValueCount are or why we're unsetting 0? Can't we just array_shift($customValueCount)
?
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 don't know what this code does either :/
But at least it's more readable now.
@@ -388,17 +388,15 @@ public function alterDisplay(&$rows) { | |||
} | |||
|
|||
if (array_key_exists('civicrm_worldregion_name', $values)) { | |||
$region = $values['civicrm_worldregion_name'] ?? NULL; | |||
$region = ($region) ? $region : 'Unassigned'; | |||
$region = $values['civicrm_worldregion_name'] ?: 'Unassigned'; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
else { | ||
$queue_id = $_GET['q'] ?? NULL; | ||
} | ||
$queue_id = $_GET['qid'] ?? $_GET['q'] ?? NULL; |
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.
Love that we're supporting CiviCRM <1.7!
@colemanw Wow what a lot of crud you cleaned up - thanks! (CiviCRM Review Template DEL-1.2)
|
Thanks so much for the review @artfulrobot ! |
Overview
Code cleanup - fixes up situations where we check if an array key exists, and then immediately check again.
Before
Double check, first in a conditional, then again with
CRM_Utils_Array::value
or coalesce.After
Removed second check. Once is enough.