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...
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
$results = [];
- $rule->query($query);
+ $rule = CRM_Core_DAO::executeQuery($query);
while ($rule->fetch()) {
$results[$rule->id] = $rule->toArray();
AND acl.entity_table = 'civicrm_acl_role'
";
- $rule->query($query);
+ $rule = CRM_Core_DAO::executeQuery($query);
while ($rule->fetch()) {
$results[$rule->id] = $rule->toArray();
}