From 286fe4ceb02198f968caa33ac1278a6cc63815e4 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 16 Aug 2022 13:39:58 +0000 Subject: [PATCH] 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 --- src/wp-admin/includes/class-wp-filesystem-ftpext.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wp-admin/includes/class-wp-filesystem-ftpext.php b/src/wp-admin/includes/class-wp-filesystem-ftpext.php index 056e7ecd9c..c3bb635809 100644 --- a/src/wp-admin/includes/class-wp-filesystem-ftpext.php +++ b/src/wp-admin/includes/class-wp-filesystem-ftpext.php @@ -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; } /**