$module_entitycache_entities) { foreach ($module_entitycache_entities as $entity_type => $entity_info) { // Do not break modules that create the cache tables for themselves. if (!db_table_exists('cache_entity_' . $entity_type)) { $schema = drupal_get_schema_unprocessed('system', 'cache'); $schema['description'] = 'Cache table used to store' . $entity_type . ' entity records.'; db_create_table('cache_entity_' . $entity_type, $schema); $tables_created[$module][] = 'cache_entity_' . $entity_type; } } } variable_set('entity_cache_tables_created', $tables_created); } /** * Remove entity cache tables for entity types of uninstalled modules. * * @param $modules * (optional) An array of uninstalled modules. If not specified, try to remove * cache tables for all modules. */ function entity_entitycache_uninstalled_modules($modules = NULL) { // If no modules are specified or if entitycache is being uninstalled, // try to remove entitycache tables for supporting entities of all modules. if (!isset($modules) || in_array('entitycache', $modules)) { $modules = module_list(); } $tables_created = variable_get('entity_cache_tables_created'); foreach ($modules as $module) { if (!empty($tables_created[$module])) { foreach ($tables_created[$module] as $table) { db_drop_table($table); } unset($tables_created[$module]); } } variable_set('entity_cache_tables_created', $tables_created); } /** * Helper to fetch entity info about entity types that use caching. */ function _entity_entitycache_get_module_info($modules) { // Prepare a keyed array of all modules with their entity types and infos. // Structure: [module][entity][info] $entity_crud_info = entity_crud_get_info(); $info = array(); foreach ($entity_crud_info as $entity_name => $entity_info) { // Make sure that the entity info specifies a module and supports entitycache. if (!isset($entity_info['module']) || empty($entity_info['entity cache'])) { continue; } $module = $entity_info['module']; // Only treat installed modules. if (!in_array($module, $modules)) { continue; } // Add the entity info to the module key. if (!isset($info[$module])) { $info[$module] = array(); } $info[$module][$entity_name] = $entity_info; } return $info; }