[wp-testers] sorta an off the wall bug

Philip M. Hofer (Frumph) philip at frumph.net
Thu Jun 21 00:56:49 UTC 2012


When installing wordpress and running it.    It is setting the upload_path 
to be the path structure of where the upload directory is hardcoded with 
/path/to/wp-content/uploads/  so what is happening is that the wp_upload_dir 
is taking that information.

So when someone moves their site path, it's retaining the hard location, a 
user could move their system from a subdirectory to a root of it or even to 
another location altogether and do sql dumps to restore their site the 
upload_path doesn't reset for the new location



wp_upload_dir() reports this as it's error:

["error"]=> string(142) "Unable to create directory 
/home1/tkdanimc/public_html/nikkisprite/wp-content/uploads/2012/06. Is its 
parent directory writable by the server?"

^ this is because the upload_path is set to 
/home1/tkdanimc/public_html/nikkisprite/wp-content/uploads

get_stylesheet_directory()  returns this:

string(71) 
"/home/tdoherty/public_html/nikkisprite.com/wp-content/themes/comicpress"

^ which is correct because that is the new location on the new server

changing the upload_path to just wp-content/uploads of course works just 
fine





the problem actually comes from wp-admin/includes/schema.php line 931-935

if ( !$upload_path = get_option( 'upload_path' ) ) {
    $upload_path = substr( WP_CONTENT_DIR, strlen( ABSPATH ) ) . '/uploads';
    update_option( 'upload_path', $upload_path );
}
update_option( 'fileupload_url', get_option( 'siteurl' ) . '/' . 
$upload_path );

What this is doing, is hardcoding the current abspath and the WP_CONTENT_DIR 
with /uploads resulting in the absolute hardcoding of that location




What I am saying the problem is.      function wp_upload_dir()  is not 
properly stripping out the information in line 1445-1448 because the ABSPATH 
is different then it actually is hardcoded in the upload_path



Does this make sense?









More information about the wp-testers mailing list