From f8c9068b792fb98fb1812df13c9be46366e4759c Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 16 Aug 2022 13:41:14 +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. Built from https://develop.svn.wordpress.org/trunk@53898 git-svn-id: http://core.svn.wordpress.org/trunk@53457 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-filesystem-ftpext.php | 8 ++++---- wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/wp-admin/includes/class-wp-filesystem-ftpext.php b/wp-admin/includes/class-wp-filesystem-ftpext.php index 056e7ecd9c..c3bb635809 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpext.php +++ b/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; } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 533ebf6e50..aa05fc9e50 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-alpha-53897'; +$wp_version = '6.1-alpha-53898'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.