From b0a63b1ca6b1738a9e41c67241393a08c7c5da49 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 23 Feb 2023 12:43:30 -0800 Subject: [PATCH] Smarty - Fix warnings about 'mb_truncate' modifier Steps to reproduce ------------------ * Use PHP 8.1 and D7 with a default logging policy (eg "All Messages" or "Errors and Warnings") * Use "Search > Find Contacts" * On the listing page, observe a bunch of warnings Before ------ ~25 warnings, including ~10 related to modifier.mb_truncate.php After ----- ~10 warnings, none involving `mb_truncate` --- CRM/Core/Smarty/plugins/modifier.mb_truncate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CRM/Core/Smarty/plugins/modifier.mb_truncate.php b/CRM/Core/Smarty/plugins/modifier.mb_truncate.php index a58909ff05..6f81841d42 100644 --- a/CRM/Core/Smarty/plugins/modifier.mb_truncate.php +++ b/CRM/Core/Smarty/plugins/modifier.mb_truncate.php @@ -58,7 +58,7 @@ function smarty_modifier_mb_truncate($string, $length = 80, $etc = '...', } - if ($strlen($string) > $length) { + if ($strlen($string ?: '') > $length) { $length -= $strlen($etc); if (!$break_words) { $string = preg_replace('/\s+?(\S+)?$/', '', $substr($string, 0, $length + 1)); -- 2.25.1