Make WordPress Core

Changeset 53862


Ignore:
Timestamp:
08/08/2022 05:12:59 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve @since notes for some WP_Filesystem_* methods:

  • WP_Filesystem_FTPext::exists()
  • WP_Filesystem_FTPext::size()
  • WP_Filesystem_ftpsockets::exists()

The ::exists() methods were previously using the FTP NLST command, which works for directories, but is not intended to be applied to a file. This only worked most of the time due to many FTP servers being permissive and allowing to execute NLST on files, which cannot be guaranteed and appears to not be the case in newer versions of Pure-FTPd (1.0.48 or later).

With a recent change in [53860], both methods were updated for compatibility with RFC 959:

  • Both methods check if the path is a directory that can be changed into (and therefore exists).
  • WP_Filesystem_FTPext uses ftp_rawlist() (FTP LIST command) to check for file existence.
  • WP_Filesystem_ftpsockets uses file size to check for file existence.

Reference: RFC 959: File Transfer Protocol (FTP)

Follow-up to [6779], [11821], [25274], [33648], [34733], [35944], [35946], [53860].

See #51170.

Location:
trunk/src/wp-admin/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-filesystem-ftpext.php

    r53860 r53862  
    413413     *
    414414     * @since 2.5.0
    415      * @since 6.1.0 Rewrite using ftp_rawlist, uses 'LIST' on FTP server
    416      *              takes file path or directory path as parameter.
     415     * @since 6.1.0 Uses WP_Filesystem_FTPext::is_dir() to check for directory existence
     416     *              and ftp_rawlist() to check for file existence.
    417417     *
    418418     * @param string $file Path to file or directory.
     
    511511     *
    512512     * @since 2.5.0
    513      * @since 6.1.0 Update for proper return values.
     513     * @since 6.1.0 Corrected the return value: while WP_Filesystem_Base::size()
     514     *              is documented to return false on failure, ftp_size() returns -1.
    514515     *
    515516     * @param string $file Path to file.
  • trunk/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php

    r53860 r53862  
    415415     *
    416416     * @since 2.5.0
    417      * @since 6.1.0 Rewrite using file size.
     417     * @since 6.1.0 Uses WP_Filesystem_ftpsockets::is_dir() to check for directory existence
     418     *              and file size to check for file existence.
    418419     *
    419420     * @param string $file Path to file or directory.
Note: See TracChangeset for help on using the changeset viewer.