Opened 12 years ago
Closed 12 years ago
#22469 closed defect (bug) (fixed)
Remove trailing slash from UPLOADS constant
Reported by: | jbrinley | Owned by: | ryan |
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | critical | Version: | 3.5 |
Component: | Media | Keywords: | has-patch commit |
Focuses: | 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)
#3
@
12 years ago
- 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.
#5
@
12 years ago
- 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.
#6
@
12 years ago
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.
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.