Download & Extend

hook_uninstall does not clear up field instances; hook_install then tries to duplicate them

Project:Profile 2
Version:7.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (duplicate)

Issue Summary

From a virgin D7 install:

  • installing profile2
  • disabling profile2
  • uninstalling profile2 completely
  • re-installing profile2

leads to the following error:

FieldException: Attempt to create an instance of field profile_fullname on bundle main that already has an instance of that field. in field_create_instance() (line 673 of /var/www/drupal-7/modules/field/field.crud.inc).

This is because hook_uninstall doesn't clear up any of the instances created by hook_install, so the re-install tries to create a duplicate instance on the main profile bundle. Obviously this field is a proof of concept at the moment but currently it's hard to comfortably test and re-test profile2 because this error means you can't really trust your own db without completely wiping it in between re-installs.

Please find attached a patch to clean up in hook_uninstall. I think the system still needs to purge somehow after removing the instances. Would appreciate any advice on that (see comment in patch.)

AttachmentSizeStatusTest resultOperations
profile2-hook_uninstall-tidy-up-instances.patch2.3 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch profile2-hook_uninstall-tidy-up-instances.patch.View details | Re-test

Comments

#1

nobody click here