Opened 14 years ago
Closed 14 years ago
#22469 closed defect (bug) (fixed)
Remove trailing slash from UPLOADS constant
| Reported by: | jbrinley | Owned by: | ryan |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.5 |
| Component: | Media | Version: | 3.5 |
| Severity: | critical | Keywords: | has-patch commit |
| Cc: | Focuses: |
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
@
14 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
@
14 years ago
- Owner set to
- Status new → assigned
ryan, any thoughts here? Our ms-files.php + switched changes made the changes in logic rather difficult to follow.
#6
@
14 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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.