[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
Thu Jun 2 22:08:10 UTC 2022


#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:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Upload        |     Version:  3.6.1
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:  multisite
--------------------------+------------------------------
Changes (by ideag):

 * keywords:  needs-patch => has-patch


Comment:

 I took a stab at this during WordCamp Europe 2022 Contributors day. I did
 the following things:
 1. replaced the use of {{{WP_CONTENT_URL}}} in {{{_wp_upload_dir()}}} with
 a call to {{{content_url()}}}
 2. added additional logic to {{{content_url()}}} method to check if
 {{{switch_to_blog()}}} has been used and if the {{{WP_CONTENT_URL}}} has
 been set in the {{{default-constants.php}}} file, rather than explicitly
 in {{{wp-config.php}}}
 3. added an indication to {{{default-constants.php}}} to signify that the
 {{{WP_CONTENT_URL}}} wss set by WP itself rather than explicitly in {{{wp-
 config.php}}}. I'm achieving that by defining an additional constant,
 {{{WP_DYNAMIC_CONTENT_URL}}}. I don't entirely like this part, but I think
 it was the best compromise in terms of readability, reliability,
 performance and testability that I could find.
 4. updated tests to test for both the explicit {{{WP_CONTENT_URL}}}
 setting and the dynamic {{{WP_CONTENT_URL}}} setting.

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


More information about the wp-trac mailing list