Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
levelos CreditAttribution: levelos commentedThis simple patch, 37af1fba8eaacfe5856fdfc5d5aa909561c9a1ef, should take care of it.