Fix group count for delete confirmation
authorlarssandergreen <lars@wildsight.ca>
Fri, 23 Jun 2023 19:03:53 +0000 (13:03 -0600)
committerlarssandergreen <lars@wildsight.ca>
Fri, 23 Jun 2023 19:03:53 +0000 (13:03 -0600)
CRM/Group/Form/Edit.php
templates/CRM/Group/Form/Delete.tpl

index 25416f71519f35ba0b48de90069233a2f2f67409..120af8822d3bcf24a55cfaeaf5726f099f1b3eca 100644 (file)
@@ -124,12 +124,15 @@ class CRM_Group_Form_Edit extends CRM_Core_Form {
     if ($this->_action == CRM_Core_Action::DELETE) {
       if (isset($this->_id)) {
         $this->assign('title', $this->_title);
-        try {
-          $this->assign('count', CRM_Contact_BAO_Group::memberCount($this->_id));
-        }
-        catch (CRM_Core_Exception $e) {
-          // If the group is borked the query might fail but delete should be possible.
+        if (!($this->_groupValues['saved_search_id'])) {
+          try {
+            $count = CRM_Contact_BAO_Group::memberCount($this->_id);
+          }
+          catch (CRM_Core_Exception $e) {
+            // If the group is borked the query might fail but delete should be possible.
+          }
         }
+        $this->assign('count', $count ?? NULL);
         $this->setTitle(ts('Confirm Group Delete'));
       }
       if ($this->_groupValues['is_reserved'] == 1 && !CRM_Core_Permission::check('administer reserved groups')) {
index 2c4760768d738b95b5488d7154a45541d7d2ff09..4043531feac4a7aef704afaaa957466ecbefc777 100644 (file)
@@ -14,7 +14,7 @@
     <div class="messages status no-popup">
         <img src="{$config->resourceBase}i/Inform.gif" alt="{ts}status{/ts}"/>
     {ts 1=$title}Are you sure you want to delete the group %1?{/ts}<br /><br />
-    {if $count}
+    {if $count !== NULL}
         {ts count=$count plural='This group currently has %count members in it.'}This group currently has one member in it.{/ts}
     {/if}
     {ts}Deleting this group will NOT delete the member contact records. However, all contact subscription information and history for this group will be deleted.{/ts} {ts}If this group is used in CiviCRM profiles, those fields will be reset.{/ts} {ts}This action cannot be undone.{/ts}