[wp-trac] [WordPress Trac] #40072: URL from wp_get_attachment_image_src on multisite is wrong

WordPress Trac noreply at wordpress.org
Tue Mar 5 12:23:25 UTC 2019


#40072: URL from wp_get_attachment_image_src on multisite is wrong
-------------------------------------+------------------------------
 Reporter:  contremaitre             |       Owner:  (none)
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  General                  |     Version:  4.7.3
 Severity:  major                    |  Resolution:
 Keywords:  needs-patch 2nd-opinion  |     Focuses:  multisite
-------------------------------------+------------------------------
Changes (by ideag):

 * focuses:   => multisite


Comment:

 We also ran into this situation recently. We managed to narrow it down to
 the following situation. All of these have to be met:
 - A modern (post 3.5) multisite
 - default or empty `upload_path` option
 - switch to a different blog via `switch_to_blog()` function

 The core of the problem is in `_wp_upload_dir()` function. Because
 `upload_path` is default or empty, it satisfies the clause on line
 [https://core.trac.wordpress.org/browser/tags/5.1/src/wp-
 includes/functions.php#L2139 2139], so `$url` is defined the
 WP_CONTENT_URL constant  (which holds the url of the original site, not
 the one that we switched to). And the multisite logic on lines 2156-2199
 just appends `site/x` to $url, not overwriting it.

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


More information about the wp-trac mailing list