Filesystem API: Return `false` for empty paths in FTP `::exists()` methods.
When `ftp_nlist()` receives an empty path, it checks the current working directory and may return `true`. This affects: * `WP_Filesystem_FTPext::exists()` * `WP_Filesystem_ftpsockets::exists()` As the purpose of the API is to provide a consistent interface for various filesystem implementations, this commit updates the affected methods to returns `false` when an empty path is provided, bringing consistency with the other filesystem abstraction classes, specifically `WP_Filesystem_Direct` and `WP_Filesystem_SSH2`. Follow-up to [6779], [11821], [25274], [31815]. Props mkox, costdev, Zdrobau, dd32, pbiron, azaozz, mukesh27, SergeyBiryukov. Fixes #33058. Built from https://develop.svn.wordpress.org/trunk@55556 git-svn-id: http://core.svn.wordpress.org/trunk@55068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
95f3aceea7
commit
07b35de70a
|
@ -419,11 +419,22 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
* Checks if a file or directory exists.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @since 6.3.0 Returns false for an empty path.
|
||||
*
|
||||
* @param string $path Path to file or directory.
|
||||
* @return bool Whether $path exists or not.
|
||||
*/
|
||||
public function exists( $path ) {
|
||||
/*
|
||||
* Check for empty path. If ftp_nlist() receives an empty path,
|
||||
* it checks the current working directory and may return true.
|
||||
*
|
||||
* See https://core.trac.wordpress.org/ticket/33058.
|
||||
*/
|
||||
if ( '' === $path ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$list = ftp_nlist( $this->link, $path );
|
||||
|
||||
if ( empty( $list ) && $this->is_dir( $path ) ) {
|
||||
|
|
|
@ -421,11 +421,22 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
* Checks if a file or directory exists.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @since 6.3.0 Returns false for an empty path.
|
||||
*
|
||||
* @param string $path Path to file or directory.
|
||||
* @return bool Whether $path exists or not.
|
||||
*/
|
||||
public function exists( $path ) {
|
||||
/*
|
||||
* Check for empty path. If ftp::nlist() receives an empty path,
|
||||
* it checks the current working directory and may return true.
|
||||
*
|
||||
* See https://core.trac.wordpress.org/ticket/33058.
|
||||
*/
|
||||
if ( '' === $path ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$list = $this->ftp->nlist( $path );
|
||||
|
||||
if ( empty( $list ) && $this->is_dir( $path ) ) {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.3-alpha-55555';
|
||||
$wp_version = '6.3-alpha-55556';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue