[wp-trac] [WordPress Trac] #51170: FTP automatic updates are not RFC 959 compliant for NLST command
WordPress Trac
noreply at wordpress.org
Sat Mar 26 17:43:09 UTC 2022
#51170: FTP automatic updates are not RFC 959 compliant for NLST command
------------------------------+-----------------------
Reporter: giox069 | Owner: afragen
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 6.0
Component: Filesystem API | Version: 3.7
Severity: normal | Resolution:
Keywords: has-patch commit | Focuses:
------------------------------+-----------------------
Comment (by costdev):
As a safety, we could follow this flow:
1. Check if it's a directory. If `true`, it exists. Return `true`.
2. Check for the availability of the SIZE command.
- As `ftp_size()` may still exist and be callable even when the SIZE
command is not available, `function_exists()` or `is_callable()` wouldn't
be effective here.
- So how can we verify the SIZE command is available? What file do we
know exists? Oh yeah, this one (`__FILE__`)
3. If `ftp_size()` returns `-1` for `__FILE__`, we can fall back to
`ftp_nlist()`.
Like this (untested):
{{{#!php
// Use SIZE, if available.
if ( -1 !== $this->size( __FILE__ ) ) {
return -1 !== $this->size( $file );
}
// Run NLST on the directory.
$dir = dirname( $file );
$files = ftp_nlist( $this->link, dir );
return $files && in_array( $file, $files, true );
}}}
Thoughts on the approach?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51170#comment:19>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list