[wp-trac] [WordPress Trac] #20046: Unnecessary default category code remains in wp_insert_attachment

WordPress Trac wp-trac at lists.automattic.com
Thu Feb 16 06:46:13 UTC 2012


#20046: Unnecessary default category code remains in wp_insert_attachment
-------------------------+------------------------------
 Reporter:  jeremyfelt   |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Media        |     Version:
 Severity:  trivial      |  Resolution:
 Keywords:  has-patch    |
-------------------------+------------------------------
Changes (by jeremyfelt):

 * type:  defect (bug) => enhancement


Comment:

 Further clarification on what is passed to the 'set_object_terms' hook,
 located a few functions away in wp_set_object_terms, when an attachment is
 added.

 {{{
 $terms = array();
 $tt_ids = array();
 $taxonomy = 'category';
 $append = false;
 $old_tt_ids = array();

 do_action('set_object_terms', $object_id, $terms, $tt_ids, $taxonomy,
 $append, $old_tt_ids);
 }}}

 It's entirely possible a plugin is using this hook to automatically add
 category information on wp_insert_attachment, but unlikely. In reality,
 the same information ($post_ID) is passed to the 'add_attachment' and
 'edit_attachment' hooks immediately after, which would be a more reliable
 place to hook in.

 I'm going to leave the patch as is, but definitely open to this action
 hook being added directly to wp_insert_attachment as a replacement of
 wp_set_post_categories.

 Also, this is mislabeled as a bug, switching to enhancement as it's more
 for optimization & cleanup.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/20046#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list