[wp-trac] [WordPress Trac] #28013: WP_Filesystem_FTPext::exists($filename) returns false when file exists on FTP Service ( IIS/6.0 Microsoft & Linux/vsftp )

WordPress Trac noreply at wordpress.org
Fri Aug 21 07:41:07 UTC 2015


#28013: WP_Filesystem_FTPext::exists($filename) returns false when file exists on
FTP Service ( IIS/6.0 Microsoft & Linux/vsftp )
----------------------------+-----------------------------
 Reporter:  joostdekeijzer  |       Owner:  dd32
     Type:  defect (bug)    |      Status:  reopened
 Priority:  normal          |   Milestone:  4.4
Component:  Filesystem API  |     Version:  3.9.2
 Severity:  normal          |  Resolution:
 Keywords:  has-patch       |     Focuses:  administration
----------------------------+-----------------------------
Changes (by mmucklo):

 * status:  closed => reopened
 * resolution:  fixed =>


Comment:

 This fix did not work for me.

 I may be doing something wrong, and I apologize in advance for wasting
 your time if so.

 '''My update still fails'''

 I patched my 4.2 code actually (been coming across this same issue trying
 to update a 4.2 installation).

 I've been stepping through via XDEBUG and was coming to the same issue.

 In '''includes/update-core.php''' this line of code is failing.
 {{{
 if ( $wp_filesystem->exists( $from . $root . 'readme.html' ) &&
 $wp_filesystem->exists( $from . $root . 'wp-includes/version.php' ) ) {
 }}}

 '''This is calling into:'''
 wp-admin/includes/class-wp-filesystem-ftpext.php

 '''Both functions fail:'''
 It fails with ftpn_list and it fails with ftp_rawlist

 '''Maybe because input to command is a file:'''
 The reason it fails is that you're passing in a $file into a command that
 seems to require a directory as it's argument.  I may be wrong here,
 however when I pass in dirname($file) into the former command, things work
 fine.

 The docs seem to indicate the required parameter is a directory, not a
 file.
 [http://php.net/manual/en/function.ftp-nlist.php]
 [http://php.net/manual/en/function.ftp-rawlist.php]

 '''Suggestion:'''
 Maybe first try the raw list, if that doesn't work, then do a rawlist of
 dirname($file) (given dirname($file) is not empty), and then check to see
 if the list returned contains the file asked for.

 '''Maybe something similar to this:'''
 {{{
 if (empty($list) && !$this->is_dir($file) && !empty($dirname =
 dirname($file))) {
     $testList = @ftp_rawlist( $this->link, $dirname );
     if (!empty($testList)) {
         // Find if $file exists in $testList, set some flag, or $list
 itself, etc.
     }
 }
 }}}

 Let me know and I can give you a working example...

--
Ticket URL: <https://core.trac.wordpress.org/ticket/28013#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list