mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
WP Filesystem: Correctly parse the permissions field in the directory listings, and actually set it in FTP environments
Props mnelson4 for initial patch. Fixes #29548 git-svn-id: https://develop.svn.wordpress.org/trunk@32923 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
bdace7c8b5
commit
fc52d9cbb1
@ -310,7 +310,7 @@ class WP_Filesystem_Base {
|
||||
* @return string The *nix-style representation of permissions.
|
||||
*/
|
||||
public function gethchmod( $file ){
|
||||
$perms = $this->getchmod($file);
|
||||
$perms = intval( $this->getchmod( $file ), 8 );
|
||||
if (($perms & 0xC000) == 0xC000) // Socket
|
||||
$info = 's';
|
||||
elseif (($perms & 0xA000) == 0xA000) // Symbolic Link
|
||||
@ -351,6 +351,17 @@ class WP_Filesystem_Base {
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the permissions of the specified file or filepath in their octal format
|
||||
*
|
||||
* @since 4.0
|
||||
* @param string $file
|
||||
* @return string the last 3 characters of the octal number
|
||||
*/
|
||||
public function getchmod( $file ) {
|
||||
return '777';
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert *nix-style file permissions to a octal number.
|
||||
*
|
||||
|
||||
@ -384,7 +384,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||
/**
|
||||
* @staticvar bool $is_windows
|
||||
* @param string $line
|
||||
* @return string
|
||||
* @return array
|
||||
*/
|
||||
public function parselisting($line) {
|
||||
static $is_windows = null;
|
||||
@ -426,6 +426,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||
else
|
||||
$b['type'] = 'f';
|
||||
$b['perms'] = $lucifer[0];
|
||||
$b['permsn'] = $this->getnumchmodfromh( $b['perms'] );
|
||||
$b['number'] = $lucifer[1];
|
||||
$b['owner'] = $lucifer[2];
|
||||
$b['group'] = $lucifer[3];
|
||||
|
||||
@ -449,6 +449,9 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
if ( $struc['islink'] )
|
||||
$struc['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $struc['name'] );
|
||||
|
||||
// Add the Octal representation of the file permissions
|
||||
$struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] );
|
||||
|
||||
$ret[ $struc['name'] ] = $struc;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user