Fix dev/core#4461 missing links causing SK to return no results
authorcolemanw <coleman@civicrm.org>
Fri, 4 Aug 2023 12:39:00 +0000 (08:39 -0400)
committercolemanw <coleman@civicrm.org>
Fri, 4 Aug 2023 12:41:54 +0000 (08:41 -0400)
ext/search_kit/Civi/Api4/Action/SearchDisplay/AbstractRunAction.php

index 6c1269f2e1c4d87fec56ef59e8c54a1426fc2ecf..34438e515f9ca23f9ef1aca6830fdcd696cb9ed3 100644 (file)
@@ -463,8 +463,10 @@ abstract class AbstractRunAction extends \Civi\Api4\Generic\AbstractAction {
       return NULL;
     }
     $link['text'] = $text ?? $this->replaceTokens($link['text'], $data, 'view');
-    if ($link['path']) {
-      $link['url'] = $this->getUrl($this->replaceTokens($link['path'], $data, 'url', $index));
+    // Will return null if `$link[path]` is empty or if any tokens do not resolve
+    $path = $this->replaceTokens($link['path'], $data, 'url', $index);
+    if ($path) {
+      $link['url'] = $this->getUrl($path);
       $keys = ['url', 'text', 'title', 'target', 'style', 'icon'];
     }
     else {