Opened 3 months ago
Closed 3 months ago
#64426 closed defect (bug) (fixed)
WP_Filesystem_Direct::getchmod() does not handle fileperms() errors
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 7.0 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Filesystem API | Keywords: | has-patch has-unit-tests |
| Focuses: | Cc: |
Description
Description:
The
getchmod()method inWP_Filesystem_Directhas a documented FIXME:
"FIXME does not handle errors in fileperms()"
When a file doesn't exist,
fileperms()returnsfalse, which gets converted to'0'- not a valid permission string.
This PR fixes it by returning
falseon failure, matching the pattern used byowner()andgroup()in the same class.
PR: https://github.com/WordPress/wordpress-develop/pull/10637
Change History (5)
This ticket was mentioned in PR #10637 on WordPress/wordpress-develop by vietcgi.
3 months ago
#1
- Keywords has-patch has-unit-tests added
#2
@
3 months ago
- Component changed from General to Filesystem API
- Milestone changed from Awaiting Review to 7.0
vietcgi commented on PR #10637:
3 months ago
#3
@westonruter it's looking good now. Thanks
Note: See
TracTickets for help on using
tickets.
## Summary
The
getchmod()method inWP_Filesystem_Directhad a documented FIXME noting it doesn't handle errors fromfileperms().When a file doesn't exist,
fileperms()returnsfalse, which then gets passed todecoct()and returns'0'- not a valid permission string.This PR adds proper error handling to return
falseon failure, matching the pattern used by other methods in the class likeowner()andgroup().## Changes
falsewhenfileperms()failsstring|falsefalseis returned for non-existent paths## Testing
'644')falseinstead of'0'gethchmod()still works correctly (intval(false, 8)equals0, same as before)