id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc,focuses 15575,ftp upgrade fails on some system due to slash in remote destination,lordandrei,dd32,"Routinely my users were unable to upgrade plugins on Mac OS X (10.5) server hosted sites. The error occurred within upgrade.php in class-wp-upgrader.php The response was: ''Could not create directory. {{{}}}/plugins/{{{}}}/'' (At least the ftp on Max OS X (10.5) Server) The problem is that in ftp one can not do: {{{ mkdir foo/ }}} if foo doesn't exist then ""mkdir foo/"" will fail The correct syntax is to remove the end slash: {{{ mkdir foo }}} Then two solutions present themselves: Either in class-wp-upgrader.php {{{ //Protection against deleting files in any important base directories. if ( in_array( $destination, array(ABSPATH, WP_CONTENT_DIR, WP_PLUGIN_DIR, WP_CONTENT_DIR . '/themes') ) ) { $remote_destination = trailingslashit($remote_destination) . trailingslashit(basename($source)); $destination = trailingslashit($destination) . trailingslashit(basename($source)); } }}} '''Adding''' {{{ if ( substr($remote_destination,-1,1) == '/' ) { $path = substr($remote_destination,0,-1); } }}} Better, we add it to the top of ''class-wp-filestream-ftpext.php'' where the problem is occurring. Since we may not be in filesystem->ftpext when running through wp-class-upgrader.php {{{ function mkdir($path, $chmod = false, $chown = false, $chgrp = false) { }}} '''Adding''' {{{ if ( substr($path,-1,1) == '/' ) { $path = substr($path,0,-1); } }}} This however seems to be potentially an FTP client issue as I've not tested this on other servers. So the inevitable fix may yet require a server capabilities test flag so as not to screw up other servers that might require the end slash. If however the end slash is completely syntactically wrong for all mkdir commands: One potential other fix is to change {{{ $remote_destination = trailingslashit($remote_destination) . trailingslashit(basename($source)); $destination = trailingslashit($destination) . trailingslashit(basename($source)); }}} to {{{ $remote_destination = trailingslashit($remote_destination) . basename($source); $destination = trailingslashit($destination) . basename($source); }}} I'm hazarding the solution but am not sure what is the best fix for this. I will be using the mkdir hack on my system until I see how this bug pans out. Thanks -A",defect (bug),closed,normal,3.3,Filesystem API,3.0,normal,fixed,has-patch 3.2-early needs-testing,,