Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
field system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
22 Apr 2009 at 03:18 UTC
Updated:
14 May 2009 at 14:50 UTC
Jump to comment: Most recent file
Comments
Comment #1
bjaspan commentedNote that this is the last hook_field_attach_* hook that is not a pre-hook that is called before the end of its related function.
Comment #2
yched commentedI think the idea was that if you delete (mark for deletion) the instances first, then the code in hook_field_attach_delete_bundle() cannot use the usual
$instances = field_info_instances($bundle);to get the instances, because they won't show up.Why is 'call hook first, then mark for delete' problematic ?
Comment #3
yched commentedOK, got it looking at pbs.module. It does not need to actually do something about the instances in the bundle, just resynchronize according to the *new* state.
What node_type_delete() does is :
- get the type $info
- delete the type
- call the delete hook with the saved info
Maybe we should do the same here ?
- get $instances = field_info_instances($bundle);
- do the delete
- call hook_field_attach_delete_bundle with the saved $instances as a param ?
Comment #4
bjaspan commentedYes, you got the point exactly. :-) By the way, I just noticed that the PHP docs for hook_field_attach_delete_bundle() specifies that the hook is invoked after the delete operation is performed.
Your proposal looks like it would work, and it turns out we already got $instances earlier in the function. Here's a new patch.
Comment #5
yched commentedReady, then :-)
Comment #6
dries commentedCommitted to CVS HEAD. Thanks.
Comment #7
sunIt would be nice to know what "the $bundle" actually is. A string?
Comments should form a proper sentence - with a trailing full-stop (period).
Comment #8
bjaspan commentedI fixed the missing period in the comment.
$bundle is a string. It is one of the basic data types of Field API, documented elsewhere. We do not declare the types of function arguments in Drupal (though we should) so doing something different for this one function would be inconsistent.
I only added a period, so RTBC.
Comment #9
dries commentedCommitted to CVS HEAD. Thanks!