When I export my Redhen setup as a feature and attempt to install it in a profile I have created. Every time I flush cache I get this

Notice: Undefined property: RedhenOrgType::$data in redhen_org_group_redhen_org_type_update() (line 74 of /sites/all/modules/redhen/modules/redhen_org_group/redhen_org_group.module).

I am unclear why we do the following comments surrounded by tag:

function redhen_org_group_redhen_org_type_update(RedhenOrgType $org_type) {
  <strong>//**** WHY DO WE CHECK TO SEE IF THIS IS SET THEN...</strong>
  if (isset($org_type->group_settings['content_types'])) { 
    <strong>//**** SET THIS VARIABLE (that is only used once)....</strong>
    $content_types = $org_type->data['group_settings']['content_types'];

    // Delete field instances if a content type was removed.
    <strong>//**** THEN TRAVERSE THROUGH THIS ARRAY</strong>
    foreach ($org_type->group_settings['content_types'] as $old_type) {
      <strong>//**** ONLY IF THIS IS NOT SET...</strong>
      if (!isset($content_types[$old_type])) {
        $instance = field_read_instance('node', REDHEN_ORG_GROUP_FIELD, $old_type);
        if ($instance) {
          field_delete_instance($instance, FALSE);
          field_purge_batch(10);
          drupal_set_message(t('Field %label has been deleted from the %type content type.',
            array('%label' => $instance['label'], '%type' => $old_type)));
        }
      }
    }
  }

  // Create new field instances.
  redhen_org_group_create_instance($org_type);
}

Any help would be appreciated. I would suggest:

function redhen_org_group_redhen_org_type_update(RedhenOrgType $org_type) {
  if (isset($org_type->group_settings['content_types'])) {

    // Delete field instances if a content type was removed.
    foreach ($org_type->group_settings['content_types'] as $old_type) {
      if (!isset($org_type->data['group_settings']['content_types'][$old_type])) {
        $instance = field_read_instance('node', REDHEN_ORG_GROUP_FIELD, $old_type);
        if ($instance) {
          field_delete_instance($instance, FALSE);
          field_purge_batch(10);
          drupal_set_message(t('Field %label has been deleted from the %type content type.',
            array('%label' => $instance['label'], '%type' => $old_type)));
        }
      }
    }
  }

  // Create new field instances.
  redhen_org_group_create_instance($org_type);
}

I'll submit a patch but like I said I am unclear if this will cause issues down the line elsewhere. As I haven't dug deep into this module yet. Thanks for your time!

-Jesse

Comments

levelos’s picture

Status: Active » Fixed

This simple patch, 37af1fba8eaacfe5856fdfc5d5aa909561c9a1ef, should take care of it.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

  • Commit 37af1fb on 7.x-1.x, redhen-donation by levelos:
    #2118009 by levelos: RedhenOrgType undefined when using features.
    

  • Commit 37af1fb on 7.x-1.x, redhen-donation, relation-roles by levelos:
    #2118009 by levelos: RedhenOrgType undefined when using features.