Created
April 13, 2014 16:33
-
-
Save JonMcL/10591338 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Delete fields no longer used by this module. | |
| */ | |
| function hook_update_N() { | |
| $fields_to_delete = array( | |
| 'field_cost', | |
| 'field_construction_budget', | |
| 'field_construction_cost', | |
| 'field_total_budget', | |
| ); | |
| foreach ($fields_to_delete as $field_name) { | |
| field_delete_field($field_name); | |
| watchdog('module_name', 'Deleted the :field_name field from all content type instances.', array(':field_name' => $field_name)); | |
| } | |
| /** | |
| * The fields aren't really deleted until the purge function runs, ordinarily | |
| * during cron. Count the number of fields we need to purge, and add five in | |
| * case a few other miscellaneous fields are in there somehow. | |
| */ | |
| field_purge_batch(count($fields_to_delete) + 5); | |
| // THEN, in case of field type change, revert the feature | |
| features_revert(array('module_name' => array('field'))); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment