[wp-trac] [WordPress Trac] #48506: wp_mkdir_p does not support relative paths
WordPress Trac
noreply at wordpress.org
Tue Nov 5 22:53:39 UTC 2019
#48506: wp_mkdir_p does not support relative paths
--------------------------+-----------------------------
Reporter: greengremlin | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 5.2.4
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
I have a wordpress install where the uploads folder is one level above the
root path.
`/www/public/wordpress` (WordPress root)
`/www/public/uploads` (Uploads folder)
Here's the relevant `wp-config.php`:
{{{#!php
<?php
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/wordpress/');
define('WP_SITEURL', $protocol . '://' . $_SERVER['HTTP_HOST'] .
'/wordpress');
define('UPLOADS', '../uploads');
}}}
This works well and I've had no issues until recently. I just traced a bug
in the FooGallery plugin where thumbnails were not getting generated to
the fact that it was calling `wp_mkdir_p` with a path that includes `..`,
which resulted in the directory not getting created.
It seems `wp_mkdir_p` needs to resolve the relative path, before trying to
create the folder.
For example:
{{{#!php
<?php
wp_mkdir_p('/www/public/wordpress/../uploads/cache/2019/07/2019-my-pic');
}}}
Should resolve the path to `/www/public/uploads/cache/2019/07/2019-my-pic`
and create the folder using the resolved path.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48506>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list