Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Major
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.1.1
-
Fix Version/s: 4.2.1
-
Component/s: None
-
Labels:None
Description
The smart group cache-build mechanism (CRM_Contact_BAO_GroupContactCache::load) produces an out-of-memory error when processing large smart-groups. Specifically, it includes this:
--------
$dao = CRM_Core_DAO::executeQuery( $sql );
$values = array( );
while ( $dao->fetch( ) ) {
$values[] = "({$groupID},{$dao->$idName})";
}
$groupIDs = array( $groupID );
self::remove( $groupIDs );
self::store ( $groupIDs, $values );
--------
The snippet loads the full group membership into memory before writing it out – which leads to the out-of-memory exception. Recommended steps:
- Write some unit-tests for smart groups
- Update GroupContactCache to use "INSERT INTO ... SELECT ..."