Ensure that keys are set in tabValues before hitting smarty
authorEileen McNaughton <emcnaughton@wikimedia.org>
Sat, 6 Nov 2021 00:07:49 +0000 (13:07 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Sun, 7 Nov 2021 22:44:36 +0000 (11:44 +1300)
CRM/Contact/Page/View/Summary.php
templates/CRM/Contact/Page/View/Summary.tpl

index 1cfd39f9db872b7df1785884f573f547294d16dc..d05569362e600c4a09922eb15efbdf6bec45491e 100644 (file)
@@ -444,6 +444,14 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View {
 
     // now sort the tabs based on weight
     usort($allTabs, ['CRM_Utils_Sort', 'cmpFunc']);
+    $expectedKeys = ['count', 'class', 'template', 'hideCount', 'icon'];
+    foreach ($allTabs as $index => $tab) {
+      foreach ($expectedKeys as $key) {
+        if (!array_key_exists($key, $tab)) {
+          $allTabs[$index][$key] = NULL;
+        }
+      }
+    }
     return $allTabs;
   }
 
index 992ef9e2dbc03289103217e05f94b923ab139fc3..a05e5ea23b9e1f4686ee1600a1cf86f5257e4ef1 100644 (file)
     <div id="mainTabContainer">
       <ul class="crm-contact-tabs-list">
         {foreach from=$allTabs item=tabValue}
-          <li id="tab_{$tabValue.id}" class="crm-tab-button ui-corner-all{if isset($tabValue.count)} crm-count-{$tabValue.count}{/if}{if isset($tabValue.class)} {$tabValue.class}{/if}">
-            <a href="{if !empty($tabValue.template)}#contact-{$tabValue.id}{else}{$tabValue.url}{/if}" title="{$tabValue.title|escape}">
+          <li id="tab_{$tabValue.id}" class="crm-tab-button ui-corner-all{if is_numeric($tabValue.count)} crm-count-{$tabValue.count}{/if}{if $tabValue.class} {$tabValue.class}{/if}">
+            <a href="{if $tabValue.template}#contact-{$tabValue.id}{else}{$tabValue.url}{/if}" title="{$tabValue.title|escape}">
               <i class="{if !empty($tabValue.icon)}{$tabValue.icon}{else}crm-i fa-puzzle-piece{/if}" aria-hidden="true"></i>
               <span>{$tabValue.title}</span>
-              {if empty($tabValue.hideCount)}<em>{if isset($tabValue.count)}{$tabValue.count}{/if}</em>{/if}
+              {if empty($tabValue.hideCount)}<em>{if is_numeric($tabValue.count)}{$tabValue.count}{/if}</em>{/if}
             </a>
           </li>
         {/foreach}