diff --git a/core/includes/install.inc b/core/includes/install.inc index 8d7f22d..e87dce5 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -781,6 +781,24 @@ function drupal_uninstall_modules($module_list = array(), $uninstall_dependents $module_list = array_keys($module_list); } + // We have to delete bundles before uninstalling the modules that + // implement them. + // If we don't have the entity module enabled, then no need to proceed. + if (module_exists('entity')) { + $entity_modules = array_intersect($module_list, module_implements('entity_info')); + foreach($entity_modules as $module) { + // Invoke hook_entity_info(). + $entities = module_invoke($module, 'entity_info'); + // Invoke hook_entity_info_alter(). + drupal_alter('entity_info', $entities); + foreach($entities as $entity) { + foreach($entity['bundles'] as $bundle) { + field_attach_delete_bundle(key($entity), key($bundle)); + } + } + } + } + foreach ($module_list as $module) { // Uninstall the module. module_load_install($module);