From 04593c26e9d2f4b5bb2f9b963635b59df3cc1095 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Thu, 14 Jul 2022 09:43:15 +1000 Subject: [PATCH] [REF][PHP8.1] Fix issues in core extensions where passing in NULL values is no longer supported --- ext/afform/core/afform.php | 4 ++-- .../CRM/Contact/Form/Search/Custom/FullText.php | 2 +- .../Civi/Api4/Action/OAuthContactToken/Create.php | 2 +- .../Civi/Api4/Action/SearchDisplay/AbstractRunAction.php | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ext/afform/core/afform.php b/ext/afform/core/afform.php index 19f86de1ad..be15c8f322 100644 --- a/ext/afform/core/afform.php +++ b/ext/afform/core/afform.php @@ -466,13 +466,13 @@ function _afform_angular_module_name($fileBaseName, $format = 'camel') { switch ($format) { case 'camel': $camelCase = ''; - foreach (preg_split('/[-_ ]/', $fileBaseName, NULL, PREG_SPLIT_NO_EMPTY) as $shortNamePart) { + foreach (preg_split('/[-_ ]/', $fileBaseName, -1, PREG_SPLIT_NO_EMPTY) as $shortNamePart) { $camelCase .= ucfirst($shortNamePart); } return strtolower($camelCase[0]) . substr($camelCase, 1); case 'dash': - return strtolower(implode('-', preg_split('/[-_ ]|(?=[A-Z])/', $fileBaseName, NULL, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE))); + return strtolower(implode('-', preg_split('/[-_ ]|(?=[A-Z])/', $fileBaseName, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE))); default: throw new \Exception("Unrecognized format"); diff --git a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText.php b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText.php index 64cb9ba3c4..9619ff36c4 100644 --- a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText.php +++ b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText.php @@ -93,7 +93,7 @@ class CRM_Contact_Form_Search_Custom_FullText extends CRM_Contact_Form_Search_Cu $formValues['table'] = $this->getFieldValue($formValues, 'table', 'String'); $this->_table = $formValues['table']; - $formValues['text'] = trim($this->getFieldValue($formValues, 'text', 'String', '')); + $formValues['text'] = trim($this->getFieldValue($formValues, 'text', 'String', '') ?? ''); $this->_text = $formValues['text']; if (!$this->_table) { diff --git a/ext/oauth-client/Civi/Api4/Action/OAuthContactToken/Create.php b/ext/oauth-client/Civi/Api4/Action/OAuthContactToken/Create.php index 78055ededf..ddb03ce3b7 100644 --- a/ext/oauth-client/Civi/Api4/Action/OAuthContactToken/Create.php +++ b/ext/oauth-client/Civi/Api4/Action/OAuthContactToken/Create.php @@ -18,7 +18,7 @@ class Create extends \Civi\Api4\Generic\DAOCreateAction { return; } - $tag = $this->values['tag'] ?? NULL; + $tag = $this->values['tag'] ?? ''; if ('linkContact:' === substr($tag, 0, 12)) { $this->values['contact_id'] = substr($tag, 12); diff --git a/ext/search_kit/Civi/Api4/Action/SearchDisplay/AbstractRunAction.php b/ext/search_kit/Civi/Api4/Action/SearchDisplay/AbstractRunAction.php index 157bd2f900..59c209f818 100644 --- a/ext/search_kit/Civi/Api4/Action/SearchDisplay/AbstractRunAction.php +++ b/ext/search_kit/Civi/Api4/Action/SearchDisplay/AbstractRunAction.php @@ -722,7 +722,7 @@ abstract class AbstractRunAction extends \Civi\Api4\Generic\AbstractAction { * @return string */ private function replaceTokens($tokenExpr, $data, $format, $index = 0) { - if (strpos($tokenExpr, '[') !== FALSE) { + if (strpos(($tokenExpr ?? ''), '[') !== FALSE) { foreach ($this->getTokens($tokenExpr) as $token) { $val = $data[$token] ?? NULL; if (isset($val) && $format === 'view') { @@ -733,7 +733,7 @@ abstract class AbstractRunAction extends \Civi\Api4\Generic\AbstractAction { if ($format === 'url' && (!isset($replacement) || $replacement === '')) { return NULL; } - $tokenExpr = str_replace('[' . $token . ']', $replacement, $tokenExpr); + $tokenExpr = str_replace('[' . $token . ']', ($replacement ?? ''), ($tokenExpr ?? '')); } } return $tokenExpr; -- 2.25.1