Opened 11 years ago
Closed 11 years ago
#20365 closed defect (bug) (fixed)
[Patch] Fix getnumchmodfromh
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | minor | Version: | 2.6 |
Component: | Filesystem API | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
Currently, getnumchmodfromh is wrong
"-rwxrw-r--" is currently translated to
"0421420400" (which is correct),
but then, it's being translated to
0+4+2 1+4+2 0+4+0 and the last 0 is ignored -> 674
when it should be
0 4+2+1 4+2+0 4+0+0 -> 0764
The patch attached solves this issue
Attachments (3)
Change History (6)
#1
@
11 years ago
- Cc kurtpayne added
- Milestone changed from Awaiting Review to 3.5
- Severity changed from major to minor
- Version changed from 3.3.1 to 2.6
Patch looks good.
getnumchmodfromh
is responsible for the $struc[permsn]
member of the return value from dirlist
. This does not appear to be used in core, so it's not currently causing unexpected behavior or data loss. It can be a problem for any plugins / themes that use this, though.
#2
@
11 years ago
- Keywords commit added
I would personally like to remove this entirely from core.. we don't use it, and I can't find any plugins which do (although, obviously the OP here does). somewhat confusing is that getnumchmodfromh()
returns a string representation of an octal number, which is not intuitive at all.
It's also worth noting that getnumchmodfromh()
does not work for values > 0777, which it was never designed for, but yet, gethchmod
does support.
The problem being triggered here, was that getnumchmodfromh()
couldn't handle the executable bit (x) being set, all combinations of r&w worked fine, but introduce x and it would return incorrectly.
Attached is a test script (run it from a web browser in wp-admin/) which can be used to verify the behaviour.
Attached patch worksforme.
Patch to fix getnumchmodfromh (strpad on the left to replace "d" or "l" bits)