From c35a53f8bc0417e1a3d2f694cfdb28c225560f25 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Mon, 17 Mar 2014 20:16:40 +0000 Subject: [PATCH] Filesystem: Fix getchmod() for direct and ssh2 transports, for directories. props DavidAnderson. fixes #26598. git-svn-id: https://develop.svn.wordpress.org/trunk@27566 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-filesystem-direct.php | 4 ++-- src/wp-admin/includes/class-wp-filesystem-ssh2.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/includes/class-wp-filesystem-direct.php b/src/wp-admin/includes/class-wp-filesystem-direct.php index ba4ae9facd..2d4e56640a 100644 --- a/src/wp-admin/includes/class-wp-filesystem-direct.php +++ b/src/wp-admin/includes/class-wp-filesystem-direct.php @@ -194,10 +194,10 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { * FIXME does not handle errors in fileperms() * * @param string $file Path to the file. - * @return string Mode of the file (last 4 digits). + * @return string Mode of the file (last 3 digits). */ function getchmod($file) { - return substr(decoct(@fileperms($file)),3); + return substr( decoct( @fileperms( $file ) ), -3 ); } function group($file) { diff --git a/src/wp-admin/includes/class-wp-filesystem-ssh2.php b/src/wp-admin/includes/class-wp-filesystem-ssh2.php index f942989dad..30a96b1da5 100644 --- a/src/wp-admin/includes/class-wp-filesystem-ssh2.php +++ b/src/wp-admin/includes/class-wp-filesystem-ssh2.php @@ -230,7 +230,7 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base { } function getchmod($file) { - return substr(decoct(@fileperms( 'ssh2.sftp://' . $this->sftp_link . '/' . ltrim($file, '/') )),3); + return substr( decoct( @fileperms( 'ssh2.sftp://' . $this->sftp_link . '/' . ltrim( $file, '/' ) ) ), -3 ); } function group($file) {