From ff494d2524d533104983fbe559ab152092e2567c Mon Sep 17 00:00:00 2001 From: Bob Silvern Date: Sun, 5 Jun 2022 14:49:15 -0700 Subject: [PATCH] dev/core#3495 - Advanced Search - Prevent multiple trailing '%' Only add a trailing '%' if it does not already exist. --- CRM/Contact/BAO/Query.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index ce5ca8eebe..20a918c3b8 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -6309,15 +6309,13 @@ AND displayRelType.is_active = 1 public static function getWildCardedValue($wildcard, $op, $value) { if ($wildcard && $op === 'LIKE') { if (CRM_Core_Config::singleton()->includeWildCardInName && (substr($value, 0, 1) != '%')) { - return "%$value%"; + $value = "%$value"; } - else { - return "$value%"; + if (substr($value, -1, 1) != '%') { + $value = "$value%"; } } - else { - return "$value"; - } + return "$value"; } /** -- 2.25.1