[wp-trac] [WordPress Trac] #33058: $wp_filesystem->exists('') returns a wrong answer (when FS_METHOD='ftpext').

WordPress Trac noreply at wordpress.org
Mon Mar 13 23:54:04 UTC 2023


#33058: $wp_filesystem->exists('') returns a wrong answer (when
FS_METHOD='ftpext').
-----------------------------------------------+---------------------
 Reporter:  Zdrobau                            |       Owner:  (none)
     Type:  defect (bug)                       |      Status:  new
 Priority:  normal                             |   Milestone:  6.3
Component:  Filesystem API                     |     Version:  2.5
 Severity:  normal                             |  Resolution:
 Keywords:  has-patch has-testing-info commit  |     Focuses:
-----------------------------------------------+---------------------

Comment (by costdev):

 > Wondering if any of these methods support the FTP command CWD? If yes,
 seems an empty exists() may be expected to return true as it will be
 checking the current working directory?

 Some thoughts:
 - The filesystem classes have a `::cwd()` method that returns the CWD (via
 `ftp_cwd()` and such). I'm not sure why someone would want to do an exists
 on an empty string as opposed to the better (IMO) `::exists( ::cwd() )`,
 except for the specific reason that FTP checks the working directory as a
 ''sort of'' "quirk".
 - Let's say I'm going to delete something. I'm going to check `if (
 ::exists( $possible_empty_string ) )`. If that returns `true`, I'm going
 to delete it. That means potentially deleting the current working
 directory if I didn't realise I was passing `''`. Instead, I'd prefer a
 situation where if I run `if ( ::exists( $possible_empty_string ) )`, I
 get a "false" `false`, and when trying to create that directory, get a
 warning that `/your/current/working/directory/` already exists, so I know
 I need to check something.
 - The `direct` filesystem is by far the most used filesystem. For
 consistency, the other classes should ''generally'' aim to mimic its
 behaviour, rather than the other way around.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/33058#comment:19>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list