}
else {
$maxLength = $field['maxlength'] ?? NULL;
- if (!is_array($value) && $maxLength && mb_strlen($value) > $maxLength && empty($field['pseudoconstant'])) {
+ if (!is_array($value) && $maxLength && mb_strlen($value ?? '') > $maxLength && empty($field['pseudoconstant'])) {
// No ts() since this is a sysadmin-y string not seen by general users.
Civi::log()->warning('A string for field {dbName} has been truncated. The original string was {value}.', ['dbName' => $dbName, 'value' => $value]);
// The string is too long - what to do what to do? Well losing data is generally bad so let's truncate
}
public function encodeValue($value) {
- return str_replace(['<', '>'], ['<', '>'], $value);
+ return str_replace(['<', '>'], ['<', '>'], ($value ?? ''));
}
/**
}
public function decodeValue($value) {
- return str_replace(['<', '>'], ['<', '>'], $value);
+ return str_replace(['<', '>'], ['<', '>'], ($value ?? ''));
}
/**
// needs testing
$activityTypes = CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'validate');
$activityName = $params['activity_name'] ?? NULL;
- $activityName = ucfirst($activityName);
+ $activityName = ucfirst($activityName ?? '');
$activityLabel = $params['activity_label'] ?? NULL;
if ($activityLabel) {
$activityTypes = CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'create');
*/
function _civicrm_api3_contact_check_params(&$params) {
- switch (strtolower(CRM_Utils_Array::value('contact_type', $params))) {
+ switch (strtolower($params['contact_type'] ?? '')) {
case 'household':
civicrm_api3_verify_mandatory($params, NULL, ['household_name']);
break;
$returnProperties = NULL;
}
- if (substr($sort, 0, 2) == 'id') {
+ if (substr(($sort ?? ''), 0, 2) == 'id') {
$sort = $lowercase_entity . "_" . $sort;
}
*/
function _civicrm_api3_validate_date(&$params, &$fieldName, &$fieldInfo) {
[$fieldValue, $op] = _civicrm_api3_field_value_check($params, $fieldName);
- if (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE) {
+ if (strpos(($op ?? ''), 'NULL') !== FALSE || strpos(($op ?? ''), 'EMPTY') !== FALSE) {
return;
}
// https://lab.civicrm.org/dev/rc/-/issues/14
$fieldValue = 1;
}
- if (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE) {
+ if (strpos(($op ?? ''), 'NULL') !== FALSE || strpos(($op ?? ''), 'EMPTY') !== FALSE) {
return;
}
function _civicrm_api3_validate_string(&$params, &$fieldName, &$fieldInfo, $entity, $action) {
$isGet = substr($action, 0, 3) === 'get';
[$fieldValue, $op] = _civicrm_api3_field_value_check($params, $fieldName, 'String');
- if (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE || CRM_Utils_System::isNull($fieldValue)) {
+ if (strpos(($op ?? ''), 'NULL') !== FALSE || strpos(($op ?? ''), 'EMPTY') !== FALSE || CRM_Utils_System::isNull($fieldValue)) {
return;
}