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

WordPress Trac wp-trac at lists.automattic.com
Wed Feb 15 08:04:36 UTC 2012


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

Comment (by jeremyfelt):

 I may be confused, and this patch was a result of something I noticed
 while hunting out another issue, but I don't see default taxonomy being
 provided for attachments at all.

 From the current post.php code, if the post_type in wp_insert_attachment
 is set to 'attachment', which it always is, the $post_categories array is
 left empty. Only if post_type matches 'post' will it retrieve a default
 option for category.

 Because of this, wp_set_post_categories is always called with an empty
 $post_categories array, which then leads to wp_set_object_terms being
 called with an empty $terms array. This in turn calls wp_get_object_terms
 at a possible 2 different points for the original attachment ID - only
 returning a result if a plugin has previously added associated a term with
 an attachment ID - unlikely in this scenario as we're still in
 wp_insert_attachment.

 I could see moving do_action( 'set_object_terms'.... to post.php so that a
 plugin could hook in and add taxonomy to an attachment as it wishes, but I
 can't see how the remainder of the code is relevant.

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


More information about the wp-trac mailing list