From 6075598c4ce8ec0812adccd157b44982f6b2ee48 Mon Sep 17 00:00:00 2001 From: colemanw Date: Fri, 21 Jul 2023 11:34:31 -0400 Subject: [PATCH] [PHP Deprecation] trim(): Passing null to parameter #1 () of type string is deprecated --- CRM/Admin/Form/RelationshipType.php | 2 +- CRM/Contact/Page/AJAX.php | 2 +- CRM/Contribute/Form/ContributionPage/ThankYou.php | 2 +- CRM/Custom/Form/Field.php | 2 +- CRM/Utils/System.php | 6 +++--- CRM/Utils/System/Backdrop.php | 4 ++-- CRM/Utils/System/Drupal.php | 4 ++-- CRM/Utils/System/WordPress.php | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CRM/Admin/Form/RelationshipType.php b/CRM/Admin/Form/RelationshipType.php index a44d987eb3da..391b52304c47 100644 --- a/CRM/Admin/Form/RelationshipType.php +++ b/CRM/Admin/Form/RelationshipType.php @@ -162,7 +162,7 @@ public function postProcess() { $params['contact_sub_type_a'] = $cTypeA[1] ? $cTypeA[1] : 'null'; $params['contact_sub_type_b'] = $cTypeB[1] ? $cTypeB[1] : 'null'; - if (!strlen(trim(CRM_Utils_Array::value('label_b_a', $params)))) { + if (!strlen(trim($params['label_b_a'] ?? ''))) { $params['label_b_a'] = $params['label_a_b'] ?? NULL; } diff --git a/CRM/Contact/Page/AJAX.php b/CRM/Contact/Page/AJAX.php index f09be9d63c1d..99181e9276a9 100644 --- a/CRM/Contact/Page/AJAX.php +++ b/CRM/Contact/Page/AJAX.php @@ -324,7 +324,7 @@ public static function checkUserName() { } $config = CRM_Core_Config::singleton(); - $username = trim(CRM_Utils_Array::value('cms_name', $_REQUEST)); + $username = trim($_REQUEST['cms_name'] ?? ''); $params = ['name' => $username]; diff --git a/CRM/Contribute/Form/ContributionPage/ThankYou.php b/CRM/Contribute/Form/ContributionPage/ThankYou.php index 11dde185b6cb..f8cc668f0701 100644 --- a/CRM/Contribute/Form/ContributionPage/ThankYou.php +++ b/CRM/Contribute/Form/ContributionPage/ThankYou.php @@ -84,7 +84,7 @@ public static function formRule($fields, $files, $options) { // if is_email_receipt is set, the receipt message must be non-empty if (!empty($fields['is_email_receipt'])) { //added for CRM-1348 - $email = trim(CRM_Utils_Array::value('receipt_from_email', $fields)); + $email = trim($fields['receipt_from_email'] ?? ''); if (empty($email) || !CRM_Utils_Rule::email($email)) { $errors['receipt_from_email'] = ts('A valid Receipt From Email address must be specified if Email Receipt to Contributor is enabled'); } diff --git a/CRM/Custom/Form/Field.php b/CRM/Custom/Form/Field.php index 9f829ac9ddc0..a61292f666d6 100644 --- a/CRM/Custom/Form/Field.php +++ b/CRM/Custom/Form/Field.php @@ -863,7 +863,7 @@ public function postProcess() { $filter = 'null'; if ($params['data_type'] == 'ContactReference' && !empty($params['filter_selected'])) { - if ($params['filter_selected'] == 'Advance' && trim(CRM_Utils_Array::value('filter', $params))) { + if ($params['filter_selected'] == 'Advance' && trim($params['filter'] ?? '')) { $filter = trim($params['filter']); } elseif ($params['filter_selected'] == 'Group' && !empty($params['group_id'])) { diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php index 641cf3ae15d9..42eb98d4d6d8 100644 --- a/CRM/Utils/System.php +++ b/CRM/Utils/System.php @@ -648,7 +648,7 @@ public static function authenticateAbort($message, $abort) { */ public static function authenticateKey($abort = TRUE) { // also make sure the key is sent and is valid - $key = trim(CRM_Utils_Array::value('key', $_REQUEST)); + $key = trim($_REQUEST['key'] ?? ''); $docAdd = "More info at: " . CRM_Utils_System::docURL2('sysadmin/setup/jobs', TRUE); @@ -701,8 +701,8 @@ public static function authenticateScript($abort = TRUE, $name = NULL, $pass = N // auth to make sure the user has a login/password to do a shell operation // later on we'll link this to acl's if (!$name) { - $name = trim(CRM_Utils_Array::value('name', $_REQUEST)); - $pass = trim(CRM_Utils_Array::value('pass', $_REQUEST)); + $name = trim($_REQUEST['name'] ?? ''); + $pass = trim($_REQUEST['pass'] ?? ''); } // its ok to have an empty password diff --git a/CRM/Utils/System/Backdrop.php b/CRM/Utils/System/Backdrop.php index 5cd20354ccfe..d8d1b8636f66 100644 --- a/CRM/Utils/System/Backdrop.php +++ b/CRM/Utils/System/Backdrop.php @@ -605,8 +605,8 @@ public function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE $uid = $params['uid'] ?? NULL; if (!$uid) { // Load the user we need to check Backdrop permissions. - $name = CRM_Utils_Array::value('name', $params, FALSE) ? $params['name'] : trim(CRM_Utils_Array::value('name', $_REQUEST)); - $pass = CRM_Utils_Array::value('pass', $params, FALSE) ? $params['pass'] : trim(CRM_Utils_Array::value('pass', $_REQUEST)); + $name = !empty($params['name']) ? $params['name'] : trim($_REQUEST['name'] ?? ''); + $pass = !empty($params['pass']) ? $params['pass'] : trim($_REQUEST['pass'] ?? ''); if ($name) { $uid = user_authenticate($name, $pass); diff --git a/CRM/Utils/System/Drupal.php b/CRM/Utils/System/Drupal.php index ed8907df964d..756b78ec2983 100644 --- a/CRM/Utils/System/Drupal.php +++ b/CRM/Utils/System/Drupal.php @@ -522,8 +522,8 @@ public function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE $uid = $params['uid'] ?? NULL; if (!$uid) { //load user, we need to check drupal permissions. - $name = CRM_Utils_Array::value('name', $params, FALSE) ? $params['name'] : trim(CRM_Utils_Array::value('name', $_REQUEST)); - $pass = CRM_Utils_Array::value('pass', $params, FALSE) ? $params['pass'] : trim(CRM_Utils_Array::value('pass', $_REQUEST)); + $name = !empty($params['name']) ? $params['name'] : trim($_REQUEST['name'] ?? ''); + $pass = !empty($params['pass']) ? $params['pass'] : trim($_REQUEST['pass'] ?? ''); if ($name) { $uid = user_authenticate($name, $pass); diff --git a/CRM/Utils/System/WordPress.php b/CRM/Utils/System/WordPress.php index 0ea69aaa9a24..a8ec22789340 100644 --- a/CRM/Utils/System/WordPress.php +++ b/CRM/Utils/System/WordPress.php @@ -762,8 +762,8 @@ public function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE // Maybe login user. $uid = $params['uid'] ?? NULL; if (!$uid) { - $name = $name ? $name : trim(CRM_Utils_Array::value('name', $_REQUEST)); - $pass = $pass ? $pass : trim(CRM_Utils_Array::value('pass', $_REQUEST)); + $name = $name ?: trim($_REQUEST['name'] ?? ''); + $pass = $pass ?: trim($_REQUEST['pass'] ?? ''); if ($name) { $uid = wp_authenticate($name, $pass); if (!$uid) {