From 43ea360f15e557ebc8f8e11fadc7fd5041002ad1 Mon Sep 17 00:00:00 2001 From: jeremyfelt Date: Wed, 22 Jul 2026 13:38:30 -0700 Subject: [PATCH] Filesystem API: Fix inaccurate `WP_Filesystem_Direct::chmod()` file permissions comparison The use of `| 0644` alters the permission bits read from the file to a minimum floor before comparing them with the requested mode. This results in an inaccurate comparison. Removing this allows the `& 0777` mask to perform as intended: strip the filetype bits from the value returned by `fileperms( $file )` so that the current permission bits can be used for comparison with the requested mode. This was added during review as part of #64610 for consistency with other parts of core, but those are using `| 0755` and `| 0644` to ensure `FS_CHMOD_DIR` and `FS_CHMOD_FILE` are set with the minimum permission bits required. --- src/wp-admin/includes/class-wp-filesystem-direct.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/class-wp-filesystem-direct.php b/src/wp-admin/includes/class-wp-filesystem-direct.php index dad8e329b2421..33aa14ce47cb9 100644 --- a/src/wp-admin/includes/class-wp-filesystem-direct.php +++ b/src/wp-admin/includes/class-wp-filesystem-direct.php @@ -176,7 +176,7 @@ public function chmod( $file, $mode = false, $recursive = false ) { } if ( ! $recursive || ! $this->is_dir( $file ) ) { - $current_mode = fileperms( $file ) & 0777 | 0644; + $current_mode = fileperms( $file ) & 0777; /* * fileperms() populates the stat cache, so have to clear it