WordPress.org

Make WordPress Core

Opened 13 years ago

Closed 12 years ago

#10060 closed defect (bug) (fixed)

Incorrect behavior of "WP_Filesystem_FTPext -> exists"

Reported by: gothicquark Owned by: dd32
Milestone: 2.9 Priority: normal
Severity: normal Version: 2.8
Component: Filesystem API Keywords: has-patch needs-testing commit
Focuses: Cc:

Description

FTP server on my web hosting returns something like a

ftpd: /www/dirname: No such file or directory

as a response of ftp_rawlist function. So this part of code works incorrectly

function exists($file) {
  $list = @ftp_rawlist($this->link, $file, false);
  return !empty($list); //empty list = no file, so invert.
}

My temporary workaround is:

function exists($file) {
  $list = @ftp_rawlist($this->link, $file, false);
  return !(empty($list) || (strpos($list[0], "No such file or directory") !== FALSE));
}

Attachments (1)

10060.diff (515 bytes) - added by dd32 12 years ago.

Download all attachments as: .zip

Change History (7)

#2 @gothicquark
13 years ago

This works great:

$list = @ftp_nlist($this->link, $file);

#3 @dd32
13 years ago

  • Keywords needs-patch needs-testing added
  • Milestone changed from 2.8 to 2.9
  • Status changed from new to accepted

I'll try and confirm that nlist works as expected.

Bumping to 2.9 due to 2.8's close release, there'll be no time to test if this actually works correctly for the majority.

#4 @dd32
12 years ago

  • Keywords has-patch commit added; needs-patch removed

Tested on VSFtp (linux) and FileZilla on windows, Seems to work as expected with nlist()

However it needs to be mentioned that neither of these servers returned verbose errors on file-not-existing..

@dd32
12 years ago

#5 @dd32
12 years ago

Tested with files/folders which existed/didnt exist.

not sure of the need for @ there, but might as well leave it in, it'll make minimal performance difference. (I cant remember why rawlist needed it, I think it was outputting Success messages as warnings)

#6 @azaozz
12 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [11821]) Fix WP_Filesystem_FTPext->exists(), props dd32, fixes #10060

Note: See TracTickets for help on using tickets.