Opened 7 months ago
Closed 7 months ago
#64426 closed defect (bug) (fixed)
WP_Filesystem_Direct::getchmod() does not handle fileperms() errors
| Reported by: | vietcgi | Owned by: | westonruter |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.0 |
| Component: | Filesystem API | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
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.
7 months ago
#1
- Keywords has-patch has-unit-tests added
vietcgi commented on PR #10637:
7 months ago
#3
@westonruter it's looking good now. Thanks
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
## 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)