[wp-trac] [WordPress Trac] #23686: wp_handle_(upload|sideload) have a lot of copy-pasted code from each other

WordPress Trac noreply at wordpress.org
Thu Jul 17 18:55:19 UTC 2014


#23686: wp_handle_(upload|sideload) have a lot of copy-pasted code from each other
------------------------------+------------------
 Reporter:  nbachiyski        |       Owner:
     Type:  enhancement       |      Status:  new
 Priority:  normal            |   Milestone:  4.0
Component:  Upload            |     Version:  3.6
 Severity:  normal            |  Resolution:
 Keywords:  has-patch commit  |     Focuses:
------------------------------+------------------

Comment (by wonderboymusic):

 Just did a bunch of testing - [attachment:23686.3.diff] is good to go.
 There were 3 esoteric places where these functions diverged. To test, load
 this somewhere:

 {{{
 require_once( ABSPATH . 'wp-admin/includes/file.php' );
 require_once( ABSPATH . 'wp-admin/includes/media.php' );
 media_sideload_image(
 'http://cdn3.pitchfork.com/albums/20890/homepage_large.16aa901a.jpg',
 {YOUR_POST_ID} );
 }}}

 Turns out, `$post_id` should be optional all the way down the line. The
 only function that actually uses it for data is `wp_insert_attachment()`,
 which allows `0`

--
Ticket URL: <https://core.trac.wordpress.org/ticket/23686#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list