Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-19831

Function CRM_Contact_BAO_Group::getGroupsHierarchy performes bad with 3000 groups

    Details

    • Type: Improvement
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.7
    • Fix Version/s: 4.7.16
    • Component/s: None
    • Labels:
    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      None
    • Funding Source:
      Contributed Code
    • Verified?:
      No

      Description

      The function getGroupsHierarchy in CRM_Contact_BAO_Group is performing very slow when a site has loads of groups.

      This caused by the while loop and an array_merge in that loop (see https://github.com/civicrm/civicrm-core/blob/4.7.14/CRM/Contact/BAO/Group.php#L1150). Array merge is bad performing if one of the arrays contains more than 20 elements. This was the case at the socialist party their installation contains more than 2867 groups. The loop it self was called 2867 times and the array with $roots contained 775 elements.

      The total duration of this function is around 800 ms.

        Attachments

          Activity

            People

            • Assignee:
              seamuslee Seamus Lee
              Reporter:
              grapio Jaap Jansma
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: