SearchKit - Fix check for smarty syntax in rewrite output
authorcolemanw <coleman@civicrm.org>
Tue, 4 Jul 2023 17:57:31 +0000 (13:57 -0400)
committercolemanw <coleman@civicrm.org>
Tue, 4 Jul 2023 17:57:31 +0000 (13:57 -0400)
Fixes dev/core#4405

ext/search_kit/Civi/Api4/Action/SearchDisplay/AbstractRunAction.php

index 5b099ab59e84e3e69f62e6856d2fb5fb9aa35a2b..f2f60e68c096a133308d89b8404bf9d6657e4417 100644 (file)
@@ -283,9 +283,10 @@ abstract class AbstractRunAction extends \Civi\Api4\Generic\AbstractAction {
    * @return string
    */
   private function rewrite(array $column, array $data): string {
-    $output = $this->replaceTokens($column['rewrite'], $data, 'view');
     // Cheap strpos to skip Smarty processing if not needed
-    if (strpos($output, '{') !== FALSE) {
+    $hasSmarty = strpos($column['rewrite'], '{') !== FALSE;
+    $output = $this->replaceTokens($column['rewrite'], $data, 'view');
+    if ($hasSmarty) {
       $smarty = \CRM_Core_Smarty::singleton();
       $output = $smarty->fetchWith("string:$output", []);
     }