From 2f3dffd86c8a7ea98d8edb93243406fcbf6aafe4 Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 5 Aug 2026 11:08:14 +1200 Subject: [PATCH] Remove final calls to replaceMailingTokens, unmatchedTokens --- CRM/SMS/Form/Upload.php | 19 +++++++++++++++++-- CRM/Utils/Token.php | 6 +++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/CRM/SMS/Form/Upload.php b/CRM/SMS/Form/Upload.php index 7d82473e3ee9..1e008d9984d1 100644 --- a/CRM/SMS/Form/Upload.php +++ b/CRM/SMS/Form/Upload.php @@ -341,14 +341,14 @@ public static function formRule($params, $files, $self) { $str = CRM_Core_TokenSmarty::render(['text' => $str], [ 'smarty' => FALSE, 'contactId' => CRM_Core_Session::getLoggedInContactID(), + 'mailingId' => $mailing->id, ])['text']; $tokens = $dummy_mail->getTokens(); $str = self::replaceSubscribeInviteTokens($str); - $str = CRM_Utils_Token::replaceMailingTokens($str, $mailing, NULL, $tokens['text']); $str = CRM_Utils_Token::replaceActionTokens($str, $verp, $urls, NULL, $tokens['text']); - $unmatched = CRM_Utils_Token::unmatchedTokens($str); + $unmatched = self::unmatchedTokens($str); $contentCheck = CRM_Utils_String::htmlToText($str); if (!empty($unmatched) && 0) { @@ -437,4 +437,19 @@ public function listTokens() { return $tokens; } + /** + * Find unprocessed tokens (call this last) + * + * @param string $str + * The string to search. + * + * @return array + * Array of tokens that weren't replaced + */ + private static function unmatchedTokens($str) { + //preg_match_all('/[^\{\\\\]\{(\w+\.\w+)\}[^\}]/', $str, $match); + preg_match_all('/\{(\w+\.\w+)\}/', $str, $match); + return $match[1]; + } + } diff --git a/CRM/Utils/Token.php b/CRM/Utils/Token.php index fec48e4b3c0d..239a922edbda 100644 --- a/CRM/Utils/Token.php +++ b/CRM/Utils/Token.php @@ -163,7 +163,7 @@ public static function tokenEscapeSmarty($string) { * @return string * The processed string * - * @deprecated + * @deprecated will be removed around 6.30 */ public static function &replaceMailingTokens( $str, @@ -172,6 +172,7 @@ public static function &replaceMailingTokens( $knownTokens = NULL, $escapeSmarty = FALSE ) { + CRM_Core_Error::deprecatedFunctionWarning('token processor'); $mailingContext = $mailing->id ? ['mailingId' => (int) $mailing->id] : []; $tokenProcessor = new TokenProcessor(\Civi::dispatcher(), $mailingContext + [ 'controller' => __CLASS__, @@ -742,8 +743,11 @@ public static function replaceSubscribeInviteTokens($str) { * * @return array * Array of tokens that weren't replaced + * + * @deprecated since 6.18 will be removed around 6.30 */ public static function &unmatchedTokens(&$str) { + CRM_Core_Error::deprecatedFunctionWarning('no alternative'); //preg_match_all('/[^\{\\\\]\{(\w+\.\w+)\}[^\}]/', $str, $match); preg_match_all('/\{(\w+\.\w+)\}/', $str, $match); return $match[1];