Make WordPress Core

Opened 7 years ago

Last modified 3 years ago

#33058 new defect (bug)

$wp_filesystem->exists('') returns a wrong answer (when FS_METHOD='ftpext').

Reported by: Zdrobau Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Filesystem API Keywords:
Focuses: Cc:


If the method $wp_filesystem->exists() is called with an empty string and FS_METHOD = 'ftpext' then the result is true, I think it is wrong, because when FS_METHOD is defined as 'direct' returns false.

Change History (7)

#1 @dd32
7 years ago

  • Version 4.2.2 deleted

Personally I think calling with an empty string is the incorrect behaviour here.

FTP is most likely returning that the current directory exists (Since that's what leaving the parameter off the ls -la calls will do)

#2 @Zdrobau
7 years ago

I want to use the method WP_Upgrader::install_package() with

$args['clear_destination'] = true

In it exists the following code that causes problems:

$removed = true;
if ( $wp_filesystem->exists( $remote_destination ) ) {
    $removed = $wp_filesystem->delete( $remote_destination, true );

#3 @dd32
7 years ago

If $remote_destination is an empty string, you've got deeper problems.

Sounds like the destination parameter to WP_Upgrader::install_package() is invalid, doesn't exist, or something else around that.

#4 @Zdrobau
7 years ago

I got this error because I use the following methods:

WP_Upgrader::download_package(); WP_Upgrader::unpack_package()

, and I want to install a theme from the zip archive that have a name like

theme-name-.-templates-.- 1.0.1-.-md5.zip

in a folder like


None of them has the option to rename this. When I call



$args['destination'] = WP_CONTENT_DIR . '/ themes /' . 'theme-name-parent'


FS_METHOD = 'direct'

this is possible. But not when

FS_METHOD = 'ftpext'

I think that


method should have the same behavior in both cases.

This ticket was mentioned in Slack in #core by jorbin. View the logs.

7 years ago

#6 @dd32
7 years ago

Is it possible to attach a plugin which shows the behaviour you're seeing?

This ticket was mentioned in Slack in #core-customize by celloexpressions. View the logs.

5 years ago

Note: See TracTickets for help on using tickets.