From 2faa890ff83eb9b53ae0f7aa25a8e173381c69de Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Sat, 19 Nov 2022 18:04:35 -0500 Subject: [PATCH] php8 don't pass null as string --- CRM/Core/DAO.php | 3 +++ CRM/Utils/Type.php | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index c3f275de79..f5f376fa12 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -2219,6 +2219,9 @@ SELECT contact_id * @return string */ public static function escapeString($string) { + if ($string === NULL) { + return ''; + } static $_dao = NULL; if (!$_dao) { // If this is an atypical case (e.g. preparing .sql file before CiviCRM diff --git a/CRM/Utils/Type.php b/CRM/Utils/Type.php index 56e465cbac..d83fbbe83f 100644 --- a/CRM/Utils/Type.php +++ b/CRM/Utils/Type.php @@ -465,7 +465,9 @@ class CRM_Utils_Type { } if ($abort) { - $data = htmlentities($data); + // Note the string 'NULL' is just for display purposes here and to avoid + // passing real null to htmlentities - it's not for database queries. + $data = htmlentities($data ?? 'NULL'); throw new CRM_Core_Exception("$name (value: $data) is not of the type $type"); } -- 2.25.1