[wp-trac] [WordPress Trac] #32774: Improve WP_Filesystem::dirlist() format consistency

WordPress Trac noreply at wordpress.org
Wed Jun 24 07:05:59 UTC 2015

#32774: Improve WP_Filesystem::dirlist() format consistency
 Reporter:  dd32            |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Filesystem API  |    Version:
 Severity:  minor           |   Keywords:
  Focuses:                  |
 At present the return values of dirlist() between the various methods are
 scattered between several different formats

 ||Field||Direct||FTP Ext||FTP Sockets||SSH2||
 ||size||Yes||Yes||Yes or `<DIR>`||Yes||
 ||lastmodunix||Unix Timestamp||No||No||Unix Timestamp||
 ||lastmod||`Nov 15`||No||No||`Nov 15`||
 ||time||`02:12:48`||Unix Timestamp||Unix Timestamp||`02:12:48`||
 ||type||`d` or `f`||`d`, `f`, or `l`||`d`, `f`, or `l`||`d` or `f`||

 If the FTP Server was Windows, it'd complicate it further by not returning
 certain fields, using different data in them, or getting confused and not
 returning any data.

 The attached patch boils it down to a consistent result of `[
 'filename.ext' => [...], ...]` with the nested arrays of:
 ||time||Unix Timestamp of last modified||
 ||size||File size or false for Directories||
 ||type||`d`, `f`, or `l` for Directory, File, or Link respectively||
 ||perms||A formatted human-readable `drwxr-xr-x`||
 ||permsn||A octal as string `'0755'` for Back-compat purposes||
 ||owner||Owner ID or name||
 ||group||Group ID or name||
 ||files||If it's a recursive directory lookup, a nested array of files||

 A number of these are only got back-compat or to match the FTP output -
 most of these fields are not used by WordPress at all - Specifically
 `group`, `owner`, `perms`, `permsn`, and `time` are ignored 100% by
 WordPress (along with a lot of the methods)
 Changing this has some back-compat issues for any plugins doing anything
 special with the fields - however they've had to work around the fields
 returning random content already, so this shouldn't be a huge issue (or
 they were already broken)

Ticket URL: <https://core.trac.wordpress.org/ticket/32774>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list