From 03946c1634adc7bf4eaa5ba7d341821febb60670 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 22 Sep 2021 17:25:45 -0700 Subject: [PATCH] (REF) TokenCompatSubscriber - Simplify expression that replaces unknown tokens Additionally, this uses the regex from `TokenProcessor` instead of the regex from `CRM_Utils_Token`. These differ in whether they capture the '|filter' expressions. --- Civi/Token/TokenCompatSubscriber.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/Civi/Token/TokenCompatSubscriber.php b/Civi/Token/TokenCompatSubscriber.php index bef111009a..3b49684471 100644 --- a/Civi/Token/TokenCompatSubscriber.php +++ b/Civi/Token/TokenCompatSubscriber.php @@ -414,17 +414,10 @@ class TokenCompatSubscriber implements EventSubscriberInterface { */ public function onRender(TokenRenderEvent $e): void { $useSmarty = !empty($e->context['smarty']); - $remainingTokens = \CRM_Utils_Token::getTokens($e->string); - - if ($remainingTokens) { - foreach ($remainingTokens as $part1 => $part2) { - $e->string = preg_replace( - '/(?string - ); - } - } + $e->string = $e->getTokenProcessor()->visitTokens($e->string, function() { + // For historical consistency, we filter out unrecognized tokens. + return ''; + }); if ($useSmarty) { $smartyVars = []; -- 2.25.1