[wp-trac] [WordPress Trac] #25650: When switching between blogs, wp_upload_dir 'baseurl' and 'url' may be pointing to the current blog not the switched one

WordPress Trac noreply at wordpress.org
Mon Oct 21 14:36:08 UTC 2013


#25650: When switching between blogs, wp_upload_dir 'baseurl' and 'url' may be
pointing to the current blog not the switched one
--------------------------+-----------------------------
 Reporter:  igmoweb       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Upload        |    Version:  3.6.1
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 Only tested on subfolder multisite (I don't have a way to test on a
 subdomain install right now).

 It seems very similar to ticket #23483 but I'm not sure if it should be
 treated the same:

 Example with two blogs in a network:
 - www.mydomain.com/my-source-blog (ID:5)
 - www.mydomain.com/my-destination-blog (ID:15)

 I discover this while trying to move a post with images from a blog to
 another. The post is copied and images inside the post are copied too.

 Starting point: The current blog ID is 15 (my-destination-blog). I'm
 trying to get upload URLs from the current blog:


 {{{
 switch_to_blog( 5 );
 $source_upload_dir = wp_upload_dir();
 $source_upload_baseurl = $source_upload_dir['baseurl'];
 restore_current_blog();

 $destination_upload_dir = wp_upload_dir();
 $destination_upload_baseurl = $destination_upload_dir ['baseurl'];
 }}}

 At this point, $source_upload_baseurl  is:

 {{{
 http://www.mydomain.com/my-destination-blog/wp-content/uploads/sites/5
 }}}

 Where should be:

 {{{
 http://www.mydomain.com/my-source-blog/wp-content/uploads/sites/5
 }}}

 $destination_upload_baseurl is fine.

 It seems that if get_option( 'upload_url_path' ) returns false,
 wp_upload_dir() makes use of WP_CONTENT_URL constant that is set to the
 current blog URL at the beggining of the execution (in default-
 constants.php):

 {{{
 define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
 }}}

 This value obviously does not change when switching a blog.

--
Ticket URL: <http://core.trac.wordpress.org/ticket/25650>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list