WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 4 months ago

#32774 new defect (bug)

Improve WP_Filesystem::dirlist() format consistency

Reported by: dd32 Owned by:
Milestone: Priority: normal
Severity: minor Version:
Component: Filesystem API Keywords:
Focuses: Cc:
PR Number:

Description

At present the return values of dirlist() between the various methods are scattered between several different formats

FieldDirectFTP ExtFTP SocketsSSH2
nameYesYesYesYes
permsYesYesYesYes
permsnYesYesYesYes
numberfalseYesYesfalse
ownerYesYesYesYes
groupYesYesYesYes
sizeYesYesYes or <DIR>Yes
lastmodunixUnix TimestampNoNoUnix Timestamp
lastmodNov 15NoNoNov 15
time02:12:48Unix TimestampUnix Timestamp02:12:48
yearNoMaybeMaybeNo
monthNoNovNovNo
dayNo1515No
hourNo0202No
minuteNo1212No
typed or fd, f, or ld, f, or ld or f
isdirNoYesYesNo
islinkNoYesYesNo

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:

FieldValue
nameFilename
timeUnix Timestamp of last modified
sizeFile size or false for Directories
typed, f, or l for Directory, File, or Link respectively
permsA formatted human-readable drwxr-xr-x
permsnA octal as string '0755' for Back-compat purposes
ownerOwner ID or name
groupGroup ID or name
filesIf 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)

Attachments (1)

32774.diff (19.5 KB) - added by dd32 4 years ago.

Download all attachments as: .zip

Change History (1)

@dd32
4 years ago

Note: See TracTickets for help on using tickets.