From edccc70d4b488b8c1134fb9cfdeeb3443ce83310 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 22 Dec 2025 01:18:31 +0000 Subject: [PATCH] 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 --- wp-admin/includes/class-wp-filesystem-direct.php | 11 +++++++---- wp-includes/version.php | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/wp-admin/includes/class-wp-filesystem-direct.php b/wp-admin/includes/class-wp-filesystem-direct.php index 2efd5b000a..ed22a821a1 100644 --- a/wp-admin/includes/class-wp-filesystem-direct.php +++ b/wp-admin/includes/class-wp-filesystem-direct.php @@ -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 ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 33ef7eaabc..056fa2c7e6 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.