#37743 closed defect (bug) (wontfix)
Setting UPLOADS constant's path prefixes the path with ABSPATH instead of WP_CONTENT_DIR
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Media | Keywords: | |
Focuses: | Cc: |
Description
On line 1921 if wp-includes/functions.php the base path of the $dir variable is WP_CONTENT_DIR. But if you set the UPLOADS constant, then the prefixing path is ABSPATH (line 1941).
This works fine if your uploads directory is in the ABSPATH directory. But if you have the WordPress source in a different directory than your content, you can't set the path appropriately.
Use case:
WordPress source lives in a 'src' directory.
WordPress content (plugins, themes, uploads) live in 'app' directory, a sibling of 'src'
You want to rename the uploads directory to 'media' or something more semantic to what you're using it for.
The way wp-includes/functions.php is setup now, getting the above scenario is impossible unless someone hacks the core.
Suggested fix: Don't prefix the UPLOADS constant with anything. Allow the user to set the root path.
That would mean changing line 1941 from
$dir = ABSPATH . UPLOADS;
to
$dir = UPLOADS;
Change History (4)
#1
follow-up:
↓ 3
@
9 years ago
- Component changed from General to Media
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
#3
in reply to:
↑ 1
@
9 years ago
Thanks for the response. Prefixing the path two different ways in the same function seemed like a bug. But since that is by design I'll try something else.
The first two options won't work for my scenario.
The third option wouldn't work in my situation either, because the function checks to see if it's an absolute path by checking if it has the ABSPATH
in it. If it doesn't (which it wouldn't if WP_CONTENT_DIR
and ABSPATH
are siblings) then it prefixes the path with ABSPATH
.
I'll give the fourth one a try. I wasn't familiar with that filter. But if I can set that to be completely custom, it should work for me.
Again, I really appreciate your response!
Hi @jtwebb,
We can't change the behaviour of the
UPLOADS
constant, as it's documented to be relative toABSPATH
.The options you have available to you are:
UPLOADS
for relative toABSPATH
WP_CONTENT_DIR
and have the uploads live atWP_CONTENT_DIR/uploads
upload_path
andupload_dir
options within WordPress, which may be absolute OR relative toABSPATH
. (See Settings -> Media)upload_dir
filter and set it to something completely customWith those options available to you, I don't think we're going to add a new constant for an absolute path to the uploads directory.
WordPress encourages the usage of filters over constants, as they're much more flexible, and the options allow changing it for most other use-cases.
While I'm marking this ticket as
wontfix
it's possible to continue discussion, and a Trac gardener can re-open it if needed.