Filesystem API: Resolve FIXME comment for WP_Filesystem_Direct::getchmod() by explicitly returning '0' in error case.

Developed in https://github.com/WordPress/wordpress-develop/pull/10637

Follow-up to [11831].

Props vietcgi, westonruter.
See #10304.
Fixes #64426.

Built from https://develop.svn.wordpress.org/trunk@61398


git-svn-id: http://core.svn.wordpress.org/trunk@60710 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter
2025-12-22 01:18:31 +00:00
parent 46045c50d7
commit edccc70d4b
2 changed files with 8 additions and 5 deletions

View File

@@ -249,15 +249,18 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
/**
* Gets the permissions of the specified file or filepath in their octal format.
*
* FIXME does not handle errors in fileperms()
*
* @since 2.5.0
*
* @param string $file Path to the file.
* @return string Mode of the file (the last 3 digits).
* @return string Mode of the file (the last 3 digits), or the string "0" on failure.
*/
public function getchmod( $file ) {
return substr( decoct( @fileperms( $file ) ), -3 );
$perms = @fileperms( $file );
if ( false === $perms ) {
return '0';
}
return substr( decoct( $perms ), -3 );
}
/**

View File

@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '7.0-alpha-61397';
$wp_version = '7.0-alpha-61398';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.