Commit 25399584 authored by Jorrit's avatar Jorrit

Optimize performance of og_get_all_group_entity()

For sites with many entity types and bundles `og_get_all_group_entity()` becomes unnecessarily slow.
The function uses `og_is_group_type()` to determine whether a bundle is a group type. This function checks the bundles of field `OG_GROUP_FIELD`.
With this change `og_get_all_group_entity()` reads the bundles of `OG_GROUP_FIELD` directly, which is much faster.
parent f4c9434f
......@@ -2490,15 +2490,17 @@ function og_is_group_content_type($entity_type, $bundle_name) {
function og_get_all_group_entity() {
$return = array();
foreach (entity_get_info() as $entity_type => $entity_value) {
foreach ($entity_value['bundles'] as $bundle => $bundle_value) {
if (og_is_group_type($entity_type, $bundle)) {
$return[$entity_type] = check_plain($entity_value['label']);
// At least one bundle of the entity can be a group, so break.
$field = field_info_field(OG_GROUP_FIELD);
if (empty($field['bundles'])) {
return $return;
$entity_types = array_keys($field['bundles']);
foreach ($entity_types as $entity_type) {
$entity_info = entity_get_info($entity_type);
$return[$entity_type] = check_plain($entity_info['label']);
return $return;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment