Opened 6 months ago
Closed 6 months ago
#22469 closed defect (bug) (fixed)
Remove trailing slash from UPLOADS constant
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.5 |
| Component: | Media | Version: | 3.5 |
| Severity: | critical | Keywords: | has-patch commit |
| Cc: |
Description
When building the uploads URL for multisite, wp_upload_dir() does this:
$url = str_replace( UPLOADS, 'files', $url );
Problem is, UPLOADS has a trailing slash; $url does not. That means that all image URLs look like http://example.com/wp-content/blogs.dir/123/files/YYYY/MM/image-file.png
I'm not sure if UPLOADS should be set without the trailing slash, or if wp_upload_dir() should untrailingslashit() before doing the str_replace()
Attachments (2)
Change History (11)
- Keywords has-patch added
Looks like it works pretty well to just apply untrailingslashit() when doing the str_replace(). I can't find any other places in core where UPLOADS is used that the trailing slash might matter. Patch attached.
I'm trying to figure out what is different from 3.4 to 3.5. I don't see it.
- Owner set to ryan
- Status changed from new to assigned
ryan, any thoughts here? Our ms-files.php + switched changes made the changes in logic rather difficult to follow.
dotcom uses that block of code from uploads-wpcom.diff to override all of the juggling wp_upload_dir() does, juggling that ends in the wrong result. It wasn't just slashes that were wrong, IIRC.
dotcom doesn't put trailing slashes on either UPLOADS or BLOGUPLOADDIR.
22469_untrailingslash_UPLOADS.diff seems safe although I too am failing to see what would cause a slashing change vs. 3.4.
comment:7
markjaquith — 6 months ago
I've confirmed the issue.
In 3.4.2, both have trailing slashes.
In trunk, $url does not have a trailing slash.
Looking into an appropriate solution.
comment:8
markjaquith — 6 months ago
- Keywords commit added
jbrinley's patch looks like the correct solution.
comment:9
markjaquith — 6 months ago
- Resolution set to fixed
- Status changed from assigned to closed
In 22736:

ryan mentioned they needed some extra code on WordPress.com to make this work. Maybe they were working around the same bug. Not sure. I've uploaded the patch they're using here.