When determining whether to add a clause filtering activity types the permitted types
are compared to all types. If all are permitted no clause is needed.
However, without this sort it is incorrectly seeing them as not matching and adding extraneous joins
foreach ($types as $type) {
$permittedActivityTypes[$type['activity_type_id']] = (int) $type['activity_type_id'];
}
+ asort($permittedActivityTypes);
Civi::$statics[__CLASS__]['permitted_activity_types'][$userID] = $permittedActivityTypes;
}
return Civi::$statics[__CLASS__]['permitted_activity_types'][$userID];