[wp-trac] [WordPress Trac] #15575: ftp upgrade fails on some system due to slash in remote destination

WordPress Trac wp-trac at lists.automattic.com
Wed Nov 24 22:01:23 UTC 2010


#15575: ftp upgrade fails on some system due to slash in remote destination
-----------------------------+----------------------------------------------
 Reporter:  lordandrei       |       Owner:                 
     Type:  defect (bug)     |      Status:  new            
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Upgrade/Install  |     Version:  3.0.1          
 Severity:  normal           |    Keywords:                 
-----------------------------+----------------------------------------------
 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. {{{<path to ftp wp-content>}}}/plugins
 /{{{<my-plugin>}}}/''

 (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

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/15575>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list