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 - Do not use concatenate operator with NULL #26901

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CRM/Activity/BAO/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ public static function create(array &$params) {
);
}
else {
$q = "action=view&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid=" . CRM_Utils_Array::value('source_contact_id', $params) . "&context=home";
$q = "action=view&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid=" . ($params['source_contact_id'] ?? '') . "&context=home";
if ($activity->activity_type_id != CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Email')) {
$url = CRM_Utils_System::url('civicrm/activity', $q);
if ($activity->activity_type_id == CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Print PDF Letter')) {
Expand All @@ -466,21 +466,21 @@ public static function create(array &$params) {
}
else {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/activity/add',
"action=update&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid=" . CRM_Utils_Array::value('source_contact_id', $params) . "&context=home"
"action=update&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid=" . ($params['source_contact_id'] ?? '') . "&context=home"
);
}

if (CRM_Core_Permission::check("delete activities")) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/activity',
"action=delete&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid=" . CRM_Utils_Array::value('source_contact_id', $params) . "&context=home"
"action=delete&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid=" . ($params['source_contact_id'] ?? '') . "&context=home"
);
}
}
else {
$url = CRM_Utils_System::url('civicrm/activity/view', $q);
if (CRM_Core_Permission::check('delete activities')) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/activity',
"action=delete&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid=" . CRM_Utils_Array::value('source_contact_id', $params) . "&context=home"
"action=delete&reset=1&id={$activity->id}&atype={$activity->activity_type_id}&cid=" . ($params['source_contact_id'] ?? '') . "&context=home"
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contribute/BAO/ContributionPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ public static function sendMail($contactID, $values, $isTest = FALSE, $returnMes
}

if ($values['is_email_receipt']) {
$sendTemplateParams['from'] = CRM_Utils_Array::value('receipt_from_name', $values) . ' <' . $values['receipt_from_email'] . '>';
$sendTemplateParams['from'] = ($values['receipt_from_name'] ?? '') . ' <' . $values['receipt_from_email'] . '>';
$sendTemplateParams['toName'] = $displayName;
$sendTemplateParams['toEmail'] = $email;
$sendTemplateParams['cc'] = $values['cc_receipt'] ?? NULL;
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contribute/Form/SoftCredit.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public static function setDefaultValues(&$defaults, &$form) {
$pcpId = $pcpInfo['pcp_id'] ?? NULL;
$pcpTitle = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $pcpId, 'title');
$contributionPageTitle = CRM_PCP_BAO_PCP::getPcpPageTitle($pcpId, 'contribute');
$defaults['pcp_made_through'] = CRM_Utils_Array::value('sort_name', $pcpInfo) . " :: " . $pcpTitle . " :: " . $contributionPageTitle;
$defaults['pcp_made_through'] = ($pcpInfo['sort_name'] ?? '') . " :: " . $pcpTitle . " :: " . $contributionPageTitle;
$defaults['pcp_made_through_id'] = $pcpInfo['pcp_id'] ?? NULL;
$defaults['pcp_display_in_roll'] = $pcpInfo['pcp_display_in_roll'] ?? NULL;
$defaults['pcp_roll_nickname'] = $pcpInfo['pcp_roll_nickname'] ?? NULL;
Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/BAO/CustomValueTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public static function create($customParams, $parentOperation = NULL) {
|| $fieldExtends === 'Organization'
|| $fieldExtends === 'Household'
) {
$paramFieldsExtendContactForEntities[$entityID]['custom_' . CRM_Utils_Array::value('custom_field_id', $field)] = $field['custom_field_id'] ?? NULL;
$paramFieldsExtendContactForEntities[$entityID]['custom_' . ($field['custom_field_id'] ?? '')] = $field['custom_field_id'] ?? NULL;
}
}

Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/BAO/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public static function addDashlet(&$params) {
if (!empty($params['instanceURL'])) {
$query = "SELECT id
FROM `civicrm_dashboard`
WHERE url LIKE '" . CRM_Utils_Array::value('instanceURL', $params) . "&%'";
WHERE url LIKE '" . ($params['instanceURL'] ?? '') . "&%'";
$dashboardID = CRM_Core_DAO::singleValueQuery($query);
}

Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ protected function formatParamsForPaymentProcessor($fields) {
*/
protected function prepareParamsForPaymentProcessor($params) {
// also add location name to the array
$params["address_name-{$this->_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-{$this->_bltID}"] = ($params['billing_first_name'] ?? '') . ' ' . ($params['billing_middle_name'] ?? '') . ' ' . ($params['billing_last_name'] ?? '');
$params["address_name-{$this->_bltID}"] = trim($params["address_name-{$this->_bltID}"]);
// Add additional parameters that the payment processors are used to receiving.
if (!empty($params["billing_state_province_id-{$this->_bltID}"])) {
Expand Down
2 changes: 1 addition & 1 deletion CRM/Event/BAO/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ public static function sendMail($contactID, $values, $participantId, $isTest = F
];
}
else {
$sendTemplateParams['from'] = CRM_Utils_Array::value('confirm_from_name', $values['event']) . " <" . CRM_Utils_Array::value('confirm_from_email', $values['event']) . ">";
$sendTemplateParams['from'] = ($values['event']['confirm_from_name'] ?? '') . " <" . ($values['event']['confirm_from_email'] ?? '') . ">";
$sendTemplateParams['toName'] = $displayName;
$sendTemplateParams['toEmail'] = $notifyEmail;
$sendTemplateParams['autoSubmitted'] = TRUE;
Expand Down
2 changes: 1 addition & 1 deletion CRM/Event/BAO/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ public static function &importableFields($contactType = 'Individual', $status =
$extIdentifier = $contactFields['external_identifier'] ?? NULL;
if ($extIdentifier) {
$tmpContactField['external_identifier'] = $extIdentifier;
$tmpContactField['external_identifier']['title'] = CRM_Utils_Array::value('title', $extIdentifier) . ' (match to contact)';
$tmpContactField['external_identifier']['title'] = ($extIdentifier['title'] ?? '') . ' (match to contact)';
}
$tmpFields['participant_contact_id']['title'] = $tmpFields['participant_contact_id']['title'] . ' (match to contact)';

Expand Down
4 changes: 2 additions & 2 deletions CRM/Event/Form/ManageEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ public function preProcess() {
$title = NULL;
if ($this->_id) {
if ($this->_isTemplate) {
$title = ts('Edit Event Template') . ' - ' . CRM_Utils_Array::value('template_title', $eventInfo);
$title = ts('Edit Event Template') . ' - ' . ($eventInfo['template_title'] ?? '');
}
else {
$configureText = $this->_isRepeatingEvent ? ts('Configure Repeating Event') : ts('Configure Event');
$title = $configureText . ' - ' . CRM_Utils_Array::value('title', $eventInfo);
$title = $configureText . ' - ' . ($eventInfo['title'] ?? '');
}
}
elseif ($this->_action & CRM_Core_Action::ADD) {
Expand Down
4 changes: 2 additions & 2 deletions CRM/Event/Form/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -1010,8 +1010,8 @@ public function submit($params) {

// also add location name to the array
$params["address_name-{$this->_bltID}"]
= CRM_Utils_Array::value('billing_first_name', $params) . ' ' .
CRM_Utils_Array::value('billing_middle_name', $params) . ' ' .
= ($params['billing_first_name'] ?? '') . ' ' .
($params['billing_middle_name'] ?? '') . ' ' .
CRM_Utils_Array::value('billing_last_name', $params);

$params["address_name-{$this->_bltID}"] = trim($params["address_name-{$this->_bltID}"]);
Expand Down
2 changes: 1 addition & 1 deletion CRM/Event/Form/ParticipantView.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function preProcess() {
$this->setTitle(ts('View Event Registration for') . ' ' . $displayName);

$roleId = $values[$participantID]['role_id'] ?? NULL;
$title = $displayName . ' (' . CRM_Utils_Array::value($roleId, $participantRoles) . ' - ' . $eventTitle . ')';
$title = $displayName . ' (' . ($participantRoles[$roleId] ?? '') . ' - ' . $eventTitle . ')';

$sep = CRM_Core_DAO::VALUE_SEPARATOR;
$viewRoles = [];
Expand Down
2 changes: 1 addition & 1 deletion CRM/Logging/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public function updateLogTableSchema($params) {
$engineChanged = isset($tableSpec['engine']) && (strtoupper($tableSpec['engine']) != $currentEngine);
$engineConfigChanged = isset($tableSpec['engine_config']) && (strtoupper($tableSpec['engine_config']) != $this->getEngineConfigForLogTable($logTable));
if ($engineChanged || ($engineConfigChanged && $params['updateChangedEngineConfig'])) {
$alterSql[] = "ENGINE=" . $tableSpec['engine'] . " " . CRM_Utils_Array::value('engine_config', $tableSpec);
$alterSql[] = "ENGINE=" . $tableSpec['engine'] . " " . ($tableSpec['engine_config'] ?? '');
}
if (!empty($tableSpec['indexes'])) {
$indexes = $this->getIndexesForTable($logTable);
Expand Down
2 changes: 1 addition & 1 deletion CRM/Mailing/Event/BAO/MailingEventForward.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public static function &forward($job_id, $queue_id, $hash, $forward_email, $from
);
//append comment if added while forwarding.
if (count($comment)) {
$message->_txtbody = CRM_Utils_Array::value('body_text', $comment) . $message->_txtbody;
$message->_txtbody = ($comment['body_text'] ?? '') . $message->_txtbody;
if (!empty($comment['body_html'])) {
$message->_htmlbody = $comment['body_html'] . '<br />---------------Original message---------------------<br />' . $message->_htmlbody;
}
Expand Down
4 changes: 2 additions & 2 deletions CRM/Member/Import/Parser/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,11 @@ public function import($values) {
}
elseif (empty($formatted['is_override'])) {
if (empty($calcStatus)) {
throw new CRM_Core_Exception('Status in import row (' . CRM_Utils_Array::value('status_id', $formatValues) . ') does not match calculated status based on your configured Membership Status Rules. Record was not imported.', CRM_Import_Parser::ERROR);
throw new CRM_Core_Exception('Status in import row (' . ($formatValues['status_id'] ?? '') . ') does not match calculated status based on your configured Membership Status Rules. Record was not imported.', CRM_Import_Parser::ERROR);
}
if ($formatted['status_id'] != $calcStatus['id']) {
//Status Hold" is either NOT mapped or is FALSE
throw new CRM_Core_Exception('Status in import row (' . CRM_Utils_Array::value('status_id', $formatValues) . ') does not match calculated status based on your configured Membership Status Rules (' . $calcStatus['name'] . '). Record was not imported.', CRM_Import_Parser::ERROR);
throw new CRM_Core_Exception('Status in import row (' . ($formatValues['status_id'] ?? '') . ') does not match calculated status based on your configured Membership Status Rules (' . $calcStatus['name'] . '). Record was not imported.', CRM_Import_Parser::ERROR);
}
}

Expand Down
2 changes: 1 addition & 1 deletion CRM/Pledge/BAO/Pledge.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public static function create(array $params): CRM_Pledge_DAO_Pledge {
}

$contributionTypes = CRM_Contribute_PseudoConstant::financialType();
$title = CRM_Contact_BAO_Contact::displayName($pledge->contact_id) . ' - (' . ts('Pledged') . ' ' . CRM_Utils_Money::format($pledge->amount, $pledge->currency) . ' - ' . CRM_Utils_Array::value($pledge->financial_type_id, $contributionTypes) . ')';
$title = CRM_Contact_BAO_Contact::displayName($pledge->contact_id) . ' - (' . ts('Pledged') . ' ' . CRM_Utils_Money::format($pledge->amount, $pledge->currency) . ' - ' . ($contributionTypes[$pledge->financial_type_id] ?? '') . ')';

// add the recently created Pledge
CRM_Utils_Recent::add($title,
Expand Down
4 changes: 2 additions & 2 deletions CRM/Report/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -3540,11 +3540,11 @@ public function filterStat(&$statistics) {
isset($field['options']) &&
is_array($field['options']) && !empty($field['options'])
) {
$value = CRM_Utils_Array::value($op, $pair) . " " .
$value = ($pair[$op] ?? '') . " " .
CRM_Utils_Array::value($val, $field['options'], $val);
}
elseif ($val || $val == '0') {
$value = CRM_Utils_Array::value($op, $pair) . " " . $val;
$value = ($pair[$op] ?? '') . " " . $val;
}
}
if ($value && empty($field['no_display'])) {
Expand Down
4 changes: 2 additions & 2 deletions CRM/Utils/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,10 @@ public static function makeFileName($name) {
// munge extension so it cannot have an embbeded dot in it
// The maximum length of a filename for most filesystems is 255 chars.
// We'll truncate at 240 to give some room for the extension.
return CRM_Utils_String::munge("{$basename}_" . CRM_Utils_Array::value('extension', $info) . "_{$uniqID}", '_', 240) . ".unknown";
return CRM_Utils_String::munge("{$basename}_" . ($info['extension'] ?? '') . "_{$uniqID}", '_', 240) . ".unknown";
}
else {
return CRM_Utils_String::munge("{$basename}_{$uniqID}", '_', 240) . "." . CRM_Utils_Array::value('extension', $info);
return CRM_Utils_String::munge("{$basename}_{$uniqID}", '_', 240) . "." . ($info['extension'] ?? '');
}
}

Expand Down
2 changes: 1 addition & 1 deletion ext/eventcart/CRM/Event/Cart/Form/Checkout/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ public function postProcess() {
"email-{$this->_bltID}" => 1,
];

$params["address_name-{$this->_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-{$this->_bltID}"] = ($params['billing_first_name'] ?? '') . ' ' . ($params['billing_middle_name'] ?? '') . ' ' . ($params['billing_last_name'] ?? '');

$params["email-{$this->_bltID}"] = $params['billing_contact_email'];
CRM_Contact_BAO_Contact::createProfileContact(
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/api/v3/ProfileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ public function createContactWithActivity(): array {
$keys = array_keys($contact['values']);
$contactId = array_pop($keys);

$this->assertEquals(0, $contact['values'][$contactId]['api.address.create']['is_error'], ' error message: ' . CRM_Utils_Array::value('error_message', $contact['values'][$contactId]['api.address.create'])
$this->assertEquals(0, $contact['values'][$contactId]['api.address.create']['is_error'], ' error message: ' . ($contact['values'][$contactId]['api.address.create']['error_message'] ?? '')
);

$activityParams = [
Expand Down