Process for removing a custom customer profile type


I am writing a contrib module customer profile types ui that provides an admin interface for adding new customer profile types dynamically through a UI. I've got the adding part and UI down for that, but I was wondering what happens when the module is later disabled or uninstalled. What processes do you recommened for handling the deletion of customer profile types to make sure data is cleared up and not orphaned on uninstall?

thanks in advance, ;)

Posted: Nov 28, 2011


aCrazyAnimal ACrazyAnimal on December 1, 2011

I've discovered my first issue with this. So I was hoping to get some feedback before proceeding with a process for dealing with them, or opening new issues.

First, I am using the latest versions of drupal 7 and modules listed here: http://drupal.org/node/1355484

When disabling my module that provides several new customer_profile_types I receive the following error when trying to edit an order using the admin UI provided by commerce:

EntityMalformedException: Missing bundle property on entity of type commerce_customer_profile. in entity_extract_ids() (line 7405 of /home/dm7/includes/common.inc).

The problem arises because the order object still has the reference field to that customer profile pane that has been disabled. Problem goes away if I delete the field, but that also deletes all of the data that has been stored using that field. At least that is what I assume it does. Can someone confirm this? Also, is all of the customer profile info that was filled out by customers deleted as well when deleting the customer profile reference field from the order?

I guess I'm looking mainly for suggestion on how to handle this properly? If someone removes a customer profile type, then what should happen in your minds?

I was thinking either there should be some methods for deleting all of the data that is attributable to the related customer profile type: i.e the reference field attached to the order and all the profiles that have ever been filled out.

.. or having someway to disable customer profile types.