From 3e8437f31f2540031b8e6bbb954434c66cd17de9 Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 30 Sep 2020 18:44:19 +1300 Subject: [PATCH] dev/core#2073 Fix a real live leak I used the same methods I had been playing with on the test class on a contribution import script and found that the object that was increasing in memory in tandem with me increasing iterations was an instance of DB_result I tracked it down to here. In essence our main DAO functions clean up after themselves - e.g when the DAO is destructed it cleans up the globals it has created. However, this older ->query() function does not do that and each time is is called increases it's memory hold. It's also worth better caching in this function... --- CRM/ACL/BAO/ACL.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CRM/ACL/BAO/ACL.php b/CRM/ACL/BAO/ACL.php index 873e6d55b7..583b3dc0ce 100644 --- a/CRM/ACL/BAO/ACL.php +++ b/CRM/ACL/BAO/ACL.php @@ -204,8 +204,6 @@ SELECT acl.* protected static function getGroupACLRoles($contact_id) { $contact_id = CRM_Utils_Type::escape($contact_id, 'Integer'); - $rule = new CRM_ACL_BAO_ACL(); - $query = " SELECT acl.* FROM civicrm_acl acl INNER JOIN civicrm_option_group og @@ -228,7 +226,7 @@ SELECT acl.* $results = []; - $rule->query($query); + $rule = CRM_Core_DAO::executeQuery($query); while ($rule->fetch()) { $results[$rule->id] = $rule->toArray(); @@ -249,7 +247,7 @@ SELECT acl.* AND acl.entity_table = 'civicrm_acl_role' "; - $rule->query($query); + $rule = CRM_Core_DAO::executeQuery($query); while ($rule->fetch()) { $results[$rule->id] = $rule->toArray(); } -- 2.25.1