From e6d438023056c9851ae9ba37e7a4e259a0e8379c Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Thu, 13 Oct 2022 02:11:23 +0000 Subject: [PATCH] [REF] Fix passing null into string functions in translation BAO --- CRM/Core/BAO/Translation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CRM/Core/BAO/Translation.php b/CRM/Core/BAO/Translation.php index f187603118..4cc2d96c28 100644 --- a/CRM/Core/BAO/Translation.php +++ b/CRM/Core/BAO/Translation.php @@ -218,12 +218,12 @@ class CRM_Core_BAO_Translation extends CRM_Core_DAO_Translation implements HookI ->addWhere('entity_table', '=', CRM_Core_DAO_AllCoreTables::getTableForEntityName($apiRequest['entity'])) ->setCheckPermissions(FALSE) ->setSelect(['entity_field', 'entity_id', 'string', 'language']); - if ((substr($userLocale->nominal, '-3', '3') !== '_NO')) { + if ((substr($userLocale->nominal ?? '', '-3', '3') !== '_NO')) { // Generally we want to check for any translations of the base language // and prefer, for example, French French over US English for French Canadians. // Sites that genuinely want to cater to both will add translations for both // and we work through preferences below. - $translations->addWhere('language', 'LIKE', substr($userLocale->nominal, 0, 2) . '%'); + $translations->addWhere('language', 'LIKE', substr($userLocale->nominal ?? '', 0, 2) . '%'); } else { // And here we have ... the Norwegians. They have three main variants which -- 2.25.1