Entity index needs to perform some cleanup actions when modules that implement it's API are uninstalled.

Comments

alexander allen’s picture

StatusFileSize
new1.32 KB

This is a "cheap" cleanup proof-of-concept. The client calls entity_index_cleanup("entity_type") and we remove the tables based on our internal table naming convention.

As you'll see on the "dirty" patch (it has commented out stuff), there is a comment fro drupal_get_schema_unprocessed("entity_index_{$entity_type}"). That returned nothing, don't know why, but I am not sure that sort of advanced metadata is needed?

One thing I am concerned about though are bundles and the Field API.

If we needed to take these into consideration, something like this would take care of deleting bundles and fields cleanly. Again, not sure if or where it would be implemented:

// $type = "entity_index_{$entity_type}", based on entity_index_schema() and entity_index_entity_info_alter()


  $bundles = field_info_bundles($type);
  foreach ($bundles as $bundle => $properties) {
    $instances = field_info_instances($type, $bundle);
    foreach ($instances as $instance) {
      field_delete_instance($instance, TRUE);
      field_purge_batch(1);
    }
  }
alexander allen’s picture

StatusFileSize
new1.53 KB

Missing some information on that last patch.

erikwebb’s picture

Status: Active » Needs work

@Alexander Allen - I'd like to keep this logic in the main entity_index module, so that any new entity implementations are simpler. I personally think the method that Entity API uses to integrate with Entity Cache method is pretty clean and consolidates the code as much as possible. #2017685: Automatically create cache tables for entities that want to support entitycache.module

alexander allen’s picture

Hey @erikwebb, I'll take a look at the Entity API + Entity Cache integration then will discuss here any ideas that come up. Thanks.