[wp-trac] [WordPress Trac] #64610: Direct filesystem chmod emits warnings even if the permissions already match

WordPress Trac noreply at wordpress.org
Fri Feb 6 19:08:13 UTC 2026


#64610: Direct filesystem chmod emits warnings even if the permissions already
match
--------------------------+------------------------------
 Reporter:  redsweater    |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+------------------------------

Comment (by redsweater):

 I am a little naive about PHP, so I approached this by trying to avoid
 calling chmod, the function that ultimately issues the warning. But I have
 since learned about @ for suppressing warnings, and maybe simply adding @
 to the chmod call would be suitable?


 {{{
 diff --git a/src/wp-admin/includes/class-wp-filesystem-direct.php b/src
 /wp-admin/includes/class-wp-filesystem-direct.php
 index ed22a821a1..6bd502a92d 100644
 --- a/src/wp-admin/includes/class-wp-filesystem-direct.php
 +++ b/src/wp-admin/includes/class-wp-filesystem-direct.php
 @@ -170,7 +170,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base
 {
                 }

                 if ( ! $recursive || ! $this->is_dir( $file ) ) {
 -                       return chmod( $file, $mode );
 +                       return @chmod( $file, $mode );
                 }

                 // Is a directory, and we want recursive.
 }}}

 In light of the slight complication with my PR needing to clear the stat
 cache after calling fileperms I could see how simpler might be better.

 Also understand if suppressing warnings isn't a high priority! I can
 suppress it in my own installs as needed.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/64610#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list