Upgrade/Install: Make WP_Filesystem_FTPext::size() return false on failure.

While `WP_Filesystem_Base::size()` is documented to return `false` on failure, `ftp_size()` returns -1, and the method documentation was recently updated to reflect that.

This commit restores the previous `@return` tag and corrects the actual return value instead, to bring consistency with all the other `WP_Filesystem_*::size()` methods:
* `WP_Filesystem_Base::size()`
* `WP_Filesystem_Direct::size()`
* `WP_Filesystem_ftpsockets::size()`
* `WP_Filesystem_SSH2::size()`
{{{
@return int|false Size of the file in bytes on success, false on failure.
}}}

This better matches the purpose of the API to provide a consistent interface for various filesystem implementations.

Follow-up to [6779], [30678], [45226], [53860], [53862].

Fixes #51170.

git-svn-id: https://develop.svn.wordpress.org/trunk@53898 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2022-08-16 13:39:58 +00:00
parent 37368555a5
commit 286fe4ceb0

View File

@ -510,14 +510,14 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
* Gets the file size (in bytes).
*
* @since 2.5.0
* @since 6.1.0 Corrected the return value: while WP_Filesystem_Base::size()
* is documented to return false on failure, ftp_size() returns -1.
*
* @param string $file Path to file.
* @return int Size of the file in bytes on success, -1 on failure.
* @return int|false Size of the file in bytes on success, false on failure.
*/
public function size( $file ) {
return ftp_size( $this->link, $file );
$size = ftp_size( $this->link, $file );
return ( $size > -1 ) ? $size : false;
}
/**